cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Create a measure based on selection of item in the chart

I have a simple bar chart in which we have categories listed against the sales. By selecting the value in the slicer for categories, we can get a measure of selected value of the slicer. However, when I click on a bar in the chart, all other bars get faded. Now, will it be possible to get the name of the category as a measure based on the category bar I clicked on the chart? 

Thanks for any suggestions

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Impactful Individual
Impactful Individual

Re: Create a measure based on selection of item in the chart

Hi @kkanda ,
Would you like to have a measure that displays selected bar?
Below is example: there are three products, showing sales on bar chart. I created a measure which returns clicked Bar.

If i click on product A, measure returns "A", if i click on product C, measure returns "C".


Dax measure: 

Clicked =
var ClickedItem = VALUES(Sheet1[Product])
RETURN
FILTER(ClickedItem,ISFILTERED(Sheet1[Product]))

Selected bar A.PNG

Selected bar C.PNG

Cheers,
Nemanja

View solution in original post

2 REPLIES 2
Highlighted
Impactful Individual
Impactful Individual

Re: Create a measure based on selection of item in the chart

Hi @kkanda ,
Would you like to have a measure that displays selected bar?
Below is example: there are three products, showing sales on bar chart. I created a measure which returns clicked Bar.

If i click on product A, measure returns "A", if i click on product C, measure returns "C".


Dax measure: 

Clicked =
var ClickedItem = VALUES(Sheet1[Product])
RETURN
FILTER(ClickedItem,ISFILTERED(Sheet1[Product]))

Selected bar A.PNG

Selected bar C.PNG

Cheers,
Nemanja

View solution in original post

Highlighted
Impactful Individual
Impactful Individual

Re: Create a measure based on selection of item in the chart

I would like to add addition to my previous post: as Power BI is interactive, if you click on one bar it automatically filters everything on that page related to selected bar (example, product A). So it might seem that this new field is not needed.
There are several ways to test formula from above.
You can insert text box and set title to specific field.

Steps below:
Text title.PNG

Step 2:

Text title 2.PNG
If you selected Based on field "Product", this text item will display correct product, but only if bar chart is selected. If bar char not selected, it will always display some value (first product). If you selected Based on field "Clicked" it will display value only if bar is selected.

Second test: display it as a list. If you select product A, list will automatically display only product A. But if you select nothing on bar chart, it will display all products.

Cheers,
Nemanja

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Power BI Desktop August 2020 Update

Power BI Desktop August 2020 Update

We have great updates this month! Click the link for the video with more info.

Top Solution Authors
Top Kudoed Authors