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
Craines
Helper II
Helper II

Filter table contents based on combinations of selected values

I have a table which I want to filter based on various combinations of Domiciles, without creating a long IF statement to determine all of the possible combinations - my DAX measure at the moment has VAR for all of the following: "Ghana", "India", "Pakistan" "Rest Of World":

 

VAR Ghana =
CALCULATE(
SELECTEDMEASURE()
, Domicile[CountryOfDomicile] = "Ghana"
)

 

I then have a RETURN statement which is an IF statement, but only adds them together or allows for each individual at a time

RETURN
IF(
SELECTEDVALUE( Domcile[CountryOfDomicile] ) = "India"
, India
, IF(
SELECTEDVALUE(Domcile[CountryOfDomicile] ) = "Ghana"
, Ghana
, IF(
SELECTEDVALUE( Domcile[CountryOfDomicile] ) = "Pakistan"
, Pakistan
, IF(
SELECTEDVALUE( Domcile[CountryOfDomicile]) = "Rest Of World"
, RestOfWorld
, India + Pakistan + Ghana + RestOfWorld
)
)
)
)

 

I would like a way to instead have a RETURN which allows for any combinations of the above (eg Ghana + Rest Of World, Ghana + Pakistan etc) depending on the end user's selection in the slicer.

 

All suggestions gratefully received!

2 REPLIES 2
amitchandak
Super User
Super User

@Craines , if Rest of the world is just a value and do have data for it in table, then use measure

 

If( "Rest Of World" in values(Domicile[CountryOfDomicile]) ,CALCULATE( SELECTEDMEASURE(), all()), SELECTEDMEASURE())

 

 

if "Rest of the world" also has data in your table, then only SELECTEDMEASURE() should do

Thank you for replying.

Rest of World is a value, the same as Ghana etc - each row in the table represents an individual, and the domicile field contains one of these values.

 

The complication is that I want to show the sum of the data according to what the end user selects, which might not just be Ghana or Rest Of World but a combination of these (or any others)

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.