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
AlixB
Frequent Visitor

Creating Dynamic Title for visual using calculated mesure

I'm trying to add a dynamic title to a visual, based on a selection of another visual, which I know how to do in theory, however the calculations to get it to work are causing a bit of a headache.

 

When a category in a table is clicked on, I want the title to show that category, however if no category is clicked I don't want the title to show all categories, but something like "All Categories"

 

My initial thought was to create a new measure with the calculation

Category = IF(DISTINCTCOUNT('Dataset1'[Account Category])>1,"All Categories",'Dataset1'[Account Category])
However this won't work because a measure doesn't allow me to use 'Dataset1'[Account Category] as the alternative outcome.
 
So I thought I'd create a measure and then a calculated column referencing the measure.
Category = IF(COUNT('Dataset1'[Account Category])>1,2,1)
TitleCategory = if('Dataset1'[Category]=2,"All Categories",'Dataser1'[Account Category])
However this doesn't work either as calculated columns can't reference a measure column with a count function.
 
So I'm stuck as to what to try next.
The logic is very simple but the system is not allowing the calculation.
Can anyone help please?

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@AlixB Check this out: https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Most-Amazing-Mind-Blowing-Dynamic-Slicer....

 

In your first formula, use MAX around your column at the end.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @AlixB 

In addition to  's reply, we need to create a measure to get dynamic result.

Measure will return aggregations, in measure we need to use Sum function to get number type value and use Max function to get text, date type values.

Try this measure:

 

Measure = 
 IF(DISTINCTCOUNT('Dataset1'[Account Category])>1,"All Categories",MAX(Dataset1[Account Category]))

 

Result is as below. 

By default:

1.png

Select Category A in other visual:

2.png

You can refer to this blog to get more details about the differences between calculated column and measure.

 

Best Regards,
Rico Zhou

 

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

Greg_Deckler
Super User
Super User

@AlixB Check this out: https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Most-Amazing-Mind-Blowing-Dynamic-Slicer....

 

In your first formula, use MAX around your column at the end.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

Thanks for that, it worked beautifully with a bit of tweaking.

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.