# 根据条件将DAX公式转换为COUNT（）或DISCTINTCOUNT（）？

##### 问题描述投票：0回答：1

``````= DISTINCTCOUNT(Table1[Column1])
``````

``````=IF(Table1[Column1] <> "XYZ",
DISTINCTCOUNT(Table1[Column1]),
COUNT(Table1[Column1])
``````

``````+----+---------+---------+
| Id | Column1 | Column2 |
+----+---------+---------+
| 1  | ABC     | A       |
+----+---------+---------+
| 1  | DEF     | A       |
+----+---------+---------+
| 1  | GHI     | B       |
+----+---------+---------+
| 1  | ABC     | A       |
+----+---------+---------+
| 1  | IIU     | XYZ     |
+----+---------+---------+
| 1  | HYW     | A       |
+----+---------+---------+
| 1  | ABC     | A       |
+----+---------+---------+
| 1  | ABC     | B       |
+----+---------+---------+
| 1  | WQW     | XYZ     |
+----+---------+---------+
| 1  | ABC     | A       |
+----+---------+---------+
| 1  | RTT     | XYZ     |
+----+---------+---------+
| 1  | PPO     | XYZ     |
+----+---------+---------+
``````

``````+----+---+---+-----+
| ID | A | B | XYZ |
+----+---+---+-----+
| 1  | 3 | 2 | 4   |
+----+---+---+-----+
``````
excel pivot-table formula dax
##### 1个回答
0

``````IF (
SELECTEDVALUE ( Table1[Column2] ) = "XYZ",
COUNT ( Table1[Column2] ),
DISTINCTCOUNT ( Table1[Column1] )
)
``````