Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

DAX If statement based on selected filter

Hello,

 

is it possible to reference a filter using a DAX formula?

e.g. IF (Filter = "Selcet All",1,2)

 

Thanks for your help

  • Hi Anonymous 

    You can do something like this, where you are comparing the total number of items in the column used to the number selected in the filter:

    IF (
        COUNTROWS ( DISTINCT ( FilterTable[FilterColumn] ) ) = COUNTROWS ( ALL ( FilterTable[FilterColumn] ) ),
        1,
        2
    )
    

    Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

    Cheers  Datanaut

1 Reply

  • AlB's avatar
    AlB
    Community Champion

    Hi Anonymous 

    You can do something like this, where you are comparing the total number of items in the column used to the number selected in the filter:

    IF (
        COUNTROWS ( DISTINCT ( FilterTable[FilterColumn] ) ) = COUNTROWS ( ALL ( FilterTable[FilterColumn] ) ),
        1,
        2
    )
    

    Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

    Cheers  Datanaut