Forum Discussion
Anonymous
9 years agoNot applicable
How to use filter with multiple values in DAX?
Hello guys, I am trying to create a measure TotalExaminationBacklog which counts all the examinationsIDs with the status WAI, VER, APP, HEL and SCH. But it seems that my measure (see image ...
- 9 years agoMy fault you have to use curly braces {...} instead of (...)
Regards
TomMartens
Super User
9 years agoHey,
my current favorite to check if one value is contained in a set of values is using the newer IN() operator
So you can write it like this
COUNTX(
'Yourtable'
,'Yourtable'[YourColumn] IN ("WAI", "VER", "APP","HEL", "SCH")
)
Edited 2017-11-09 (start):
The statement above will not work due a type, the correct statement uses curly braces, why is explained in my last post. The correct statement will look like
COUNTX(
'Yourtable'
,'Yourtable'[YourColumn] IN {"WAI", "VER", "APP","HEL", "SCH"}
)Edited 2017-11-09 (end):
Assuming that the STATUS comes from a slicer, this would also be possible
COUNTX(
'Yourtable'
,'Yourtable'[Yourcolumn] IN (ALLSELECTED('MaybeAnotherTable'[ColumnUsedInSlicer]))
)Maybe this idea helps you give another idea
Anonymous
6 years agoNot applicable
Hi Tom!!
Thank you for all your contributions to this site. I was wondering if you can help me. I have tried
TotalFires = COUNTX(Query1,Query1[INCIDENT_CATEGORY] IN {"Accidental Dwelling Fire",
"Accidental Non Domestic Fire",
"Accidental Other Primary Fire",
"Accidental Vehicle Fire",
"Accidental Small Fire",
"Chimney Fire",
"Deliberate Dwelling Fire",
"Deliberate Non Domestic Fire",
"Deliberate Small Fire",
"Deliberate Other Primary Fire",
"Deliberate Vehicle Fire"})
and the following error is returned when I try to add it to a visualisation:
The function COUNTX cannot work with values of type Boolean
I don't think my column INCIDENT_CATEGORY has any Boolean. Are you able to assist?
I'm trying to get a filtered set / count of INCIDENT_CATEGORY where INCIDENT_CATEGORY contains the values in my expression
Thank you!
Dan