Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX - How to check user segment filter selection ?

Hi,

 

I have a formula that is adaptive whenever the user select a country on the page or if no country selected (which is if the user want to see a zone).

To do this I simply check the filter like this :

IF(HASONEFILTER(COUNTRY[COUNTRY]);...;...)

This works well when I display my measure in a graph (bridge in this example). 

 

However this does not work when I display it in a grid where I also have the countries on rows. Indeed this would automatically compute the formula on one country and not by zone. 

 

How can I check the user filter only which is the selection made on the segment and ignore the row filter ?

 

Thanks for your help

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

This involves the row context in DAX calculation.

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/

For your case, just try this:

If COUNTRY table is dim table, use [COUNTRY] field from data table in a gird, do not use  [COUNTRY] field from COUNTRY table.

 

If COUNTRY table is not dim table, create a dim table, then create a relationship with Country table and use [COUNTRY] field from dim table in a gird.

 

Here is a simple pbix file, please try it.

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

COUNTRY is indeed a dim table but [COUNTRY] is not the key. It's a different hierarchy from the key that is linked to my data table. Therefore I cannot display the field from my data table.

hi, @Anonymous 

Could you share a simple sample pbix file with your expected output?

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.