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
MagikJukas
Resolver III
Resolver III

Filtering from a chart

Hi,

I have piechart, containing several values calculated from Columns and measures.

 

I wish to select a category in the chart and been able to display its value in a card.

Depending on the category I choose, the card should show the value selected in the chart.

If nothing is selecting, the total is displayed.

 

is it possible to do it in PBI?

 

 

regards

 

1 ACCEPTED SOLUTION

Ok, eventually I figured it out.

1. I created a new table containing the name of the measures I want to display. 

Table2 = {("Measure1 name",1),("Measure2 name",2)}

2. I created a new measure that switches the between column or measure

Total =IFERROR(VALUES([Table2]),""),"Measure1 name",SUM([Measure1]),"Measure2 name",SUM([Measure2]),[ALL])
 
Then in the charts, I replaced all the measures with my new "Total" and put "Table2" in the Chart legend.
I also replaced the card with "Total" measure.
 
 
Bottom line: when I select any element of the chart, the card updates the value accordingly.

View solution in original post

10 REPLIES 10
johnt75
Super User
Super User

it works for me from a pie chart to a card. try having a look at the queries generated. open Performance Analyzer and start recording, click on one of the categories in your pie chart and then copy the query generated for the card visual. paste that into DAX Studio and see what filters are being applied

I think the problem is that my piechart contains several different values (measures) instead of one with several legends.

Indeed the second solution would have worked as you suggested.

 

the main problem is if it is possible with DAX to acknowledge when a measure is selected /filtered. 

I tried Isfiltered and iscrossfiltered, but it does not recognize when selected.

 

I think the output from Performance Analyzer might still help. If you compare the queries with nothing selected and with a value selected that should show you the difference. If there is no difference then no filter is being applied and you have no hope of detecting anything, you would need to rethink how you're approaching the problem. If there is a difference, and a filter is being applied, then it should be possible to examine whatever the filter is being applied to and determine whether or not it is being filtered.

One possible method for detecting a filter on a measure might be something like

Measure is filtered =
var currentValue = [Measure]
var totalValue = CALCULATE([Measure], ALL() )
return currentValue <> totalValue

Thanks for your comment.

I am not sure I understood your formula.

 

Basically, what I should do is to use SWITCH formula, so that when a specific measure is highlighted in the piechart, it switches to that measure.

Now, how can DAX acknowledge I highlighted a given measure in the chart?

 

FYI, I ran the analyzer when highlighting a given measure in the chart.

The first step is "Cross-highlighted", I need to understand how to read that in DAX.

Any idea?

MagikJukas_0-1663142335283.png

 

 

 

In Performance Analyzer you would need to expand the entry for the card you're interested in. When you click on an item in the Performance Analyzer pane it will highlight it in the main report section so you can tell which card you have selected. Then just copy the code and examine it in DAX Studio

I do not have DAX Studio. I would have to ask my IT to install it eventually.

 

for now I found this page explaining how to create a measure that switches from a set of other measures, by clicking on a filter.

https://endjin.com/blog/2022/06/how-to-dynamically-switch-between-measures-in-power-bi-visuals-with-...

 

what I need to figure out, is if I can do with highlighting in a chart instead of a slicer.

Not sure field parameters would work in this particular case, but they're a really useful addition to Power BI.

You don't necessarily need DAX Studio to look at the code, any text editor will do, though it is a handy tool to have. The key thing to look for is any table filters created before the main query.

Ok, eventually I figured it out.

1. I created a new table containing the name of the measures I want to display. 

Table2 = {("Measure1 name",1),("Measure2 name",2)}

2. I created a new measure that switches the between column or measure

Total =IFERROR(VALUES([Table2]),""),"Measure1 name",SUM([Measure1]),"Measure2 name",SUM([Measure2]),[ALL])
 
Then in the charts, I replaced all the measures with my new "Total" and put "Table2" in the Chart legend.
I also replaced the card with "Total" measure.
 
 
Bottom line: when I select any element of the chart, the card updates the value accordingly.
johnt75
Super User
Super User

That is the default behaviour, when you make a selection in one visual on a page that selection will filter all the other visuals on that page. 

If you put the same measure which you are using in the pie chart onto a card visual, selecting a category in the pie chart will filter the card visual to only show values for that category.

Nope, from a chart to another chart or a matrix/Card it does not.

 

From a Matrix to a chart/card, indeed it works.

 

... and edit interactions are set correctly.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.