Forum Discussion
How to use filter with multiple values in DAX?
- 9 years agoMy fault you have to use curly braces {...} instead of (...)
Regards
Hey,
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
Hi Tom!!
Thank you for all your contributions to this site. I was wondering if you can help me. I have tried
- TomMartens6 years ago
Super User
Hey Anonymous ,
maybe this measure will provide what you are looking for:
TotalFires = SUMX(Query1, IF(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"} , 1 , BLANK()) )If this does not solve your problem, please start a new question.
The error is due to the fact that COUNTX is not able to count BOOLEANs, a boolean is returned by column IN {...}
Regards,
Tom- Anonymous6 years agoNot applicable
- Anonymous4 years agoNot applicable
Hi Tom,
I have come across a similar problem and your above solution works perfect for me. If wanted to use the above formular to filter by column 1 (Text values) and an additonal columns (Text values) how would that work?
For example
I want to sum column 1
Filter by column 2 (text values)
and filter by column 3 (text values)
Hope this makes sense.