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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.