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

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
nandic
Memorable Member
Memorable Member

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
nandic
Memorable Member
Memorable Member

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

nandic
Memorable Member
Memorable Member

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

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.