Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Change filter condition on basis dropdown .

Hi i'm trying write a dax, drop down containing column list. So on selection of dropdown I can swith filter conditon from Col[A] to Col[B].

Measure:

test= calculate(distinctCount(Table1[ABC]),

                          filter(Table1,Table1[A] / Table1[B] <=max(table2[col])
                          &&

                          Table1[A] / Table1[B] >=min(table2[col])

)

So, If i select A from drop down then Table1[A] or If i select B from drop down then Table1[B].

Is there any way I can achieve this. 

                                 
           

  • Hi Anonymous ,

    Write two measures, 

    Column A = calculate(distinctCount(Table1[ABC]),

                              filter(Table1,Table1[A] <=max(table2[col])
                              &&

                              Table1[A]  >=min(table2[col])

    Column B= calculate(distinctCount(Table1[ABC]),

                              filter(Table1,Table1[B] <=max(table2[col])
                              &&

                              Table1[B] >=min(table2[col])

    Then create a table: (This table is not connected to any table) Used to harvest the measure.

    Change the sort order of Column Name to Measure ID.

    Create a measure [Use this column] = SELECTEDVALUE(TABLE[Measure ID])

    Create a measure [Column A] = 1 (Instead of the = 1, it would contain your formula)

    Create a measure [Column B] = 2

    Put the column [Measure ID] on a slicer, and then I used a card to display results using measure [Use this column]

     

    If this solves your issue please mark this as the solution. Kudos are nice too!

    Nathaniel_C 

1 Reply

  • Nathaniel_C's avatar
    Nathaniel_C
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous ,

    Write two measures, 

    Column A = calculate(distinctCount(Table1[ABC]),

                              filter(Table1,Table1[A] <=max(table2[col])
                              &&

                              Table1[A]  >=min(table2[col])

    Column B= calculate(distinctCount(Table1[ABC]),

                              filter(Table1,Table1[B] <=max(table2[col])
                              &&

                              Table1[B] >=min(table2[col])

    Then create a table: (This table is not connected to any table) Used to harvest the measure.

    Change the sort order of Column Name to Measure ID.

    Create a measure [Use this column] = SELECTEDVALUE(TABLE[Measure ID])

    Create a measure [Column A] = 1 (Instead of the = 1, it would contain your formula)

    Create a measure [Column B] = 2

    Put the column [Measure ID] on a slicer, and then I used a card to display results using measure [Use this column]

     

    If this solves your issue please mark this as the solution. Kudos are nice too!

    Nathaniel_C