Forum Discussion

bi_analyst_2024's avatar
bi_analyst_2024
Frequent Visitor
1 year ago
Solved

DAX Change Filter Context

Hello

 

CustomerP1 ClassificationP2 ClassificationValue P1Value P2Delta
Customer1UpperUpper90,00075,00015,000
Customer2UpperUpper60,00050,00010,000
Customer3UpperBlank25,000Blank25,000

 

Slicers

Filters = P1

Filters = P2

Classification = Upper

 

I have a report visualisation as per the above, which allows a user to compare a customer's performance across periods based on customer classifications for that period. There are slicers on the page allowing users to change the period selected and the customer classifications i.e. upper or lower.

 

Therefore on the above a user has selected the periods and the classification of Upper. This then shows how the upper classification changed from period to period.

 

What I would also like to do is, for classification columns only, to override the filter context to show the new/previous classification in that period, if it exists. As an example, Customer3 above was a Lower customer in P2, and I would like to show this rather than it be blank?

 

Thanks in advance for any help!

 

Best regards

  • bi_analyst_2024 
    What I have understood from your provided information is, you're looking to override the slicer filter context so that for the P1 and P2 classification columns, you still show the customer's true classification in that period, even if it doesn't match the classification filter (e.g., Upper or Lower). 

    P2 True Classification = 
    CALCULATE (
        MAX ( YourTable[P2 Classification] ),
        REMOVEFILTERS ( YourTable[P2 Classification] )
    )

    This will get the P2 Classification for that row, but ignore any filters from the slicer that are filtering out the Lower classification. 

    REMOVEFILTERS() - Ensures the classification column isn't affected by slicers, allowing the "true" classification to be shown.

    MAX() - Helps retrieve the relevant value for each row based on the current filter context.

    *************************************************************************************************************************************************

    If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

    Thank you,
    Sarita 
    Linkedin 

     

5 Replies

  • v-venuppu's avatar
    v-venuppu
    Community Support

    Hi bi_analyst_2024 ,

    Thank you for reaching out to Microsoft Fabric Community.

    Thank you Akash_Varuna for the prompt response.

    I used a DAX measure that overrides the slicer filter context to return the actual classification, using REMOVEFILTERS, called "Classification_Override" - you can find it in attached .pbix file.

    The key trick is to disable interaction between the P2 Classification slicer and your table visual:

    • Click the P2 Classification slicer.
    • Go to Format → Edit interactions.
    • On your table visual, click the “No filter” icon to stop the slicer from filtering the table.

    This way:

    The slicer won’t hide customers like Customer3.

    The measure will still return the true classification, unaffected by slicer filters.

    Please find the attached .pbix file for your reference.

     

    If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

    Thank you.

     

  • bi_analyst_2024 
    What I have understood from your provided information is, you're looking to override the slicer filter context so that for the P1 and P2 classification columns, you still show the customer's true classification in that period, even if it doesn't match the classification filter (e.g., Upper or Lower). 

    P2 True Classification = 
    CALCULATE (
        MAX ( YourTable[P2 Classification] ),
        REMOVEFILTERS ( YourTable[P2 Classification] )
    )

    This will get the P2 Classification for that row, but ignore any filters from the slicer that are filtering out the Lower classification. 

    REMOVEFILTERS() - Ensures the classification column isn't affected by slicers, allowing the "true" classification to be shown.

    MAX() - Helps retrieve the relevant value for each row based on the current filter context.

    *************************************************************************************************************************************************

    If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

    Thank you,
    Sarita 
    Linkedin 

     
    • bi_analyst_2024's avatar
      bi_analyst_2024
      Frequent Visitor

      Hi - thank you for all the replies - the REMOVEFILTERS function is what I used to solve the problem - so you were correct. Thank you.

  • Hi bi_analyst_2024  For this, what you could do is create a DAX measure to override the filter context for classifications:

    Classification_Override = 
    IF(
        NOT(ISBLANK(SELECTEDVALUE('Table'[P2 Classification]))),
        SELECTEDVALUE('Table'[P2 Classification]),
        SELECTEDVALUE('Table'[P1 Classification])
    )

    The measure checks if P2 Classification exists and uses it; otherwise, it defaults to P1 Classification. Use the measure in your visual to display the correct classification dynamically.

  • Hi - thanks for the reply. That's not what I would like to achieve. In the example above Customer3's P2 classification is Lower, but it is showing as blank because the fitler context only returns Upper customers. I would like to override that to show the actual classification in the period.