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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

DAX Support: Show specific string based on number of filters / or no filters

Dear forum, I hope you can help me once again

I will start by asking the question before showing my examples: 

How does one write an expression to show a specific text string, based on how many filters on a specific dimension level have been applied?  

I am working as controller for a large global organization with several factories and trying to develop a monthly report.
I am stuck on fixing this text window with three different text string measures, showing what factory/factory group has been filtered for. (A factory group is often called a cluster).

I have done a mock-table on what the filter/dimension table structure looks like:

ras_ile_0-1598604076953.png


Based on these three dimension fields that I used as a slicer in my report, I want to write three text string measures to show what Cluster / Sub Cluster / Factory is being filtered - but in a smart way which I'll explain below.

For example: if the slicer is set so that everything - (or, nothing) is filtered, I would like the measures to show this:

Cluster Measure shows: "Cluster - All"
Sub Cluster Measure shows: "Sub Cluster - All"

Factory Measure shows: "Factory - Multiple Selected"

ras_ile_1-1598604214543.png

Similarly, if "Select All" is used, same result.

 

But if we only want to look at Poznan factory, the 3 measures should show the following:

 

ras_ile_3-1598604389559.png

 

But if we look at both Poznan and Madrid factory, I want to be able to show name of both sub-clusters, but the factory name should say "multiple factories". Like below:

 

 

2020-08-28_09-42-02.png

 

 

Any advice on this kind of DAX would be greatly appreciated.
I have thought about SELECTEDVALUE, ISFILTERED and other DAX but realized that I need to combine them with COUNT and I have got lost in the exercise.

/Rasmus 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Found a solution with some googling:


Replaced the ALLSELECTED middle part of the expression with:

COUNTROWS(FILTERS(FactoryTable[Cluster]))=1

Thanks anyway! 

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , Try a measure like

measure = "Cluster : " &
Switch(true(),
not(isfiltered(Table[Cluster])), "All",
countx(allselected(Table),Table[Cluster]) =1, selectedvalue(Table[Cluster]) ,
"Multiple Selected"
)

 

You can add other like this as per need

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

COUNTX(

ALLSELECTED(FactoryTable),FactoryTable[Cluster]) =1,

SELECTEDVALUE(FactoryTable[Cluster]),
 
 
This part is not working, probably because ALLSELECTED ignores that it is CLUSTER LEVEL.
If I only select a Factory Unit, the filter is correct.

Any idea @amitchandak if there is a different way to count how many have been selected on the higher level?
Anonymous
Not applicable

Found a solution with some googling:


Replaced the ALLSELECTED middle part of the expression with:

COUNTROWS(FILTERS(FactoryTable[Cluster]))=1

Thanks anyway! 
Anonymous
Not applicable

Hi Amit,

Thanks for your reply.

It is almost working - "All" and "Multiple" are going well. But if I just select 1 cluster, I still get "Multiple", which means that the DAX probably does not recognize the part of counting selected = 1. 

I tried adding an "IF" (IF(COUNTX.... =1) but that did not help. What do you think can be the issue? 

Anonymous
Not applicable

ras_ile_0-1598613938719.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.