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
markhollandau
Resolver I
Resolver I

Visual Title - Measure Doesn't Filter on Filter Selection

Hi,

 

I've added a measure to the Header of my Slicer. I want it to count the number of fields when not filtered, and then to adjust the value when a number of selections are made. Here are my calculations:

 

Firstly, I'm counting the distinct count of Campaign IDs: 

Total Campaign IDs = DISTINCTCOUNT('04a: Ads (fact)'[campaign_id])
 
Then I'm adding this into another measure to add to my Slicer Header:
Filter Title: Full Campaign with Count = "Full Campaign Name & ID: " &
IF([Total Campaign IDs]=1, [Total Campaign IDs] & " Campaign",
IF(ISBLANK([Total Campaign IDs]),"0 Campaigns",
[Total Campaign IDs] & " Campaigns"))
 
I've done this to change pluralise "Campaign" or to show "0 Campaigns" if there's no data.
 
On the image below, I've shown the filter with 2 selections and a visual contains the Slicer Header visual:
 
Screenshot 2024-04-05 124709.png
You'll see that slicer header shows 12 - the total number of Campaigns IDs. While the visual shows 2 - this number of Campaigns that were selected from the filter.
 
How can I get the Slicer Header to show the same value as the visual? 

 

Thanks,

Mark

1 ACCEPTED SOLUTION

HI @OwenAuger ,

 

Thanks for looking at this. It's frustrating that Power BI doesn't allow something so simple as this.

 

I think, to keep things simple, I'm going to group a card and filter together with the title in the card and use that. This will mean I don't need to add more rows into my data.

 

I really appreciate you taking the time to try figure this out for me.


Thanks,

Mark

View solution in original post

5 REPLIES 5
markhollandau
Resolver I
Resolver I

Hi @OwenAuger ,

 

Thanks for replying. I have seen an example, months ago, where the visual title did response to the filter selection. I just can't remember where I saw it.

 

There's no way to use CALCULATE or any of the FILTER functions to get around this?

 

I'd rather not create a separate visual just for the header.

 

Thanks,

Mark

Interesting 🙂
Not sure which visual that would have been, but would be interesting if you can find it again.

 

Certain custom visuals (Hierarchy Slicer and Preselected Slicer for instance) display some text indicating which (or how many) selections have been made, but this can't be customized using a measure, as this is part of the custom visual's logic rather than being evaluated by querying the model.

 

It's discussed here on this Issues page as well.

 

So I really can't see any any visual's Title can respond to its own selections by means of evaluating a measure.

Regardless of how the DAX expression is crafted, the Title measure is evaluated in a context where the filters from the slicer itself don't exist.

 

If you can find the example you're talking about that would be great, otherwise someone else may have some suggestions.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

I had another look, and the best I can come up is a bit of a hack using a "hidden" Preselected Slicer custom visual.

 

Here's what I tried (PBIX attached):

 

1. Create an additional disconnected table called something like Campaign, with a single column campaign_id containing all distinct values of campaign_id.

2. Create a table Dummy, with a single column Dummy with two rows (true & false). This needs to be placed in the Preselected Slicer's "Dirty Status" field well.

3. Create/modify the measures (shown below):

Total Campaign IDs = 
DISTINCTCOUNT ( Campaign[campaign_id] )
Filter Title: Full Campaign with Count = 
"Full Campaign Name & ID: "
    & IF (
        [Total Campaign IDs] = 1,
        [Total Campaign IDs] & " Campaign",
        IF (
            ISBLANK ( [Total Campaign IDs] ),
            "0 Campaigns",
            [Total Campaign IDs] & " Campaigns"
        )
    )
Preselected Slicer Filter = 
SELECTEDVALUE ( Campaign[campaign_id] ) IN VALUES ( '04a: Ads (fact)'[campaign_id] )

 4. Set up the Preselected Slicer as shown:

OwenAuger_0-1712304454421.png

5. Ensure the Preselected Slicer is in a "reset" state (click reset button on Header).

6. "Hide" the Preselected Slicer by reducing its size and placing it somewhere inconspicuous, such as behind the main slicer. Hiding the visual unfortunately won't work.

7. Set the main slicer title measure to Filter Title: Full Campaign with Count.

8. Now the slicer's title updates as expected:

OwenAuger_1-1712304624117.png

It's more complicated than I would like for such a simple requirement, but it works I guess.

 

It seems that we need to use such a method because Power BI refuses to apply filters to the slicer's title measure if they depend on the field used in the slicer (by relationships or DAX expressions). However the filter from the Preselected Slicer appears to break this lineage 🙂

 

Would this be a workable method? Would be interested in simpler solutions. 😅

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

HI @OwenAuger ,

 

Thanks for looking at this. It's frustrating that Power BI doesn't allow something so simple as this.

 

I think, to keep things simple, I'm going to group a card and filter together with the title in the card and use that. This will mean I don't need to add more rows into my data.

 

I really appreciate you taking the time to try figure this out for me.


Thanks,

Mark

OwenAuger
Super User
Super User

Hi Mark,

The limitation you've run into is that filters applied by making selections in a visual do not apply as filters to that visual itself (or any component of it), but only to other visuals.

 

In this case, the selections made in the slicer do not apply as filters for any measures evaluated as part of that same slicer visual, including title, subtitle, conditional formatting etc.

 

The same would apply to other visuals: e.g. bars selected in a bar chart cannot affect the title or formatting of the chart.

 

The simplest solution using core visuals would be to create a separate visual to display the title such as a "Card (new)" which has more alignment options than the original Card, or some other empty visual with just the title visible.

 

There could be some custom visuals out there that do provide this kind of functionality, but that would have to be part of the code behind the visual rather than working through filters and measure evaluation.

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

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.