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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Lauraeire_81
New Member

DAX help on category

Hi 

I am looking to display the Countries listed depending on what food items are selected in a slicer (where multiple options can be selected).

Say 'Hot Dogs', 'Corn dogs' and 'Stew' are selected, I want a measure to say something like this:

'Corn Dogs' and 'Hot dogs' found in 'America'. Count of 2. 

'Stew' is found in Ireland. Count of 1.

 

Is there any way to search on a table like this and display the items in a similar format?

Thanks in advance,

Laura

 

See table 'CountryFood' below. 

CountriesFood
AmericaHot dogs
AmericaCorn dogs
AmericaBigmacs
Ireland Stew
Ireland Cabbage and bacon
2 REPLIES 2
AilleryO
Memorable Member
Memorable Member

Hi,

 

We need more details to really help you but basically, if you want to get the selectedvalue :

Get Category List (selected ones) =
VAR LstCat = DISTINCT( Products[Category] )
VAR NbCat = COUNTROWS( LstCat )
RETURN
SWITCH( TRUE() ,
 NOT ISFILTERED( Products[Category] ) , "All cat displayed" ,
 NbCat > 10    , "Too many cat selected (" & NbCat & " categories selected)" ,
 ISFILTERED( Products[Category] ) ,  CONCATENATEX( LstCat , Products[Category] , ", ")   )
 
In this formula, I test the number of category selected, not to display the result if there are too many (more than 10). So you can adapt that part for the count you required.
Let us know if you need more details

 
AilleryO Thank you - this works.
Would it be possible to add a value if the 'Select all' value in the slicer was selected? I have 9 values and sometimes I would just want to select all of them.  Thank you. 
 
 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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