Forum Discussion

Kosh's avatar
Kosh
Frequent Visitor
1 year ago
Solved

DAX function to apply OR condition on multiple columns based on Slicers

Hi,   I have multiple slicers (Location, Gender, Age, etc). I want to count all rows for any value which matches with the slicer selection. Example - If user selected Location=US, UK + Gender=Fe...
  • Deku's avatar
    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])) 

        )

    )

  • ThxAlot's avatar
    1 year ago

    Make sure these 3 tables tbLocations, tblGender, tblAge DON'T filter each other. If so, the measure is fairly simple,

  • sjoerdvn's avatar
    sjoerdvn
    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]))   
    )