Forum Discussion
DAX function to apply OR condition on multiple columns based on Slicers
- 1 year ago
Need a all() to remove the current filter context
SelectedEmployees =
CALCULATE(
COUNTROWS(tblData),
FILTER(
All( 'tblData' ),
(tblData[Location] in VALUES(tbLocations[Locations]) ||
tblData[Gender] in VALUES(tblGender[Gender]) ||
tblData[Age] in VALUES(tblAge[AgeGroups]))
)
)
- 1 year ago
Make sure these 3 tables tbLocations, tblGender, tblAge DON'T filter each other. If so, the measure is fairly simple,
- 1 year ago
SelectedEmployees = CALCULATE( COUNTROWS(tblData), ALL('tbLocations'),ALL(tblGender), ALL(tblAge), OR(OR(tblData[Location] in VALUES(tbLocations[Locations]), tblData[Gender] in VALUES(tblGender[Gender])), tblData[Age] in VALUES(tblAge[AgeGroups])) )
Need a all() to remove the current filter context
SelectedEmployees =
CALCULATE(
COUNTROWS(tblData),
FILTER(
All( 'tblData' ),
(tblData[Location] in VALUES(tbLocations[Locations]) ||
tblData[Gender] in VALUES(tblGender[Gender]) ||
tblData[Age] in VALUES(tblAge[AgeGroups]))
)
)
Thanks for the reply. How to show this data in a table/matrix with breadkdown by any field? Using ALL in filter is giving same value for all rows table/matrix.
- sjoerdvn1 year ago
Solution Sage
SelectedEmployees = CALCULATE( COUNTROWS(tblData), ALL('tbLocations'),ALL(tblGender), ALL(tblAge), OR(OR(tblData[Location] in VALUES(tbLocations[Locations]), tblData[Gender] in VALUES(tblGender[Gender])), tblData[Age] in VALUES(tblAge[AgeGroups])) )- Kosh10 months agoFrequent Visitor
Thanks for your reply. Not sure where the issue is but the formula is not giving correct output. Example - When I select Male in Gender filter the count is 1000+, so if I select any other filter the value should either remain same or increase (as using OR filter) but the count is going down.
CALCULATE(
COUNTROWS(tblDnI), ALL(tblGender),ALL(tblSexualOrientation),ALL(tblReligion),ALL(tblDisability),all(tblOccupation),all(tblEthnicity),(tblDnI[Gender] in VALUES(tblGender[Gender])
||
tblDnI[Sexual Orientation] in VALUES(tblSexualOrientation[Sexual Orientation])
||
tblDnI[Religion] in VALUES(tblReligion[Religion])
||
tblDnI[Disabled] in VALUES(tblDisability[Disabled])
||
tblDnI[Household Occupation] in VALUES(tblOccupation[SEB])
||
tblDnI[Ethnic Origin] in VALUES(tblEthnicity[Ethnicity])
))