Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Andrea_Jess
Helper III
Helper III

Stacked Bar Chart Tooltips

Hey All,

 

I have these 3 measures to calculate Selected Year Sales, Selected Year - 1 Sales, and Selected Year - 2 Sales: 

Selected Year = CALCULATE(SUM(Data[Sales]), DATEADD(DimDate[Date], 0, YEAR) 
Selected Year - 1 = CALCULATE(SUM(Data[Sales]), DATEADD(DimDate[Date], -1, YEAR) 
Selected Year - 2 = CALCULATE(SUM(Data[Sales]), DATEADD(DimDate[Date], -2, YEAR) 

These are then put into a stacked bar chart with Vendor on the x axis and the three measures in the Values field. 

The issue i'm having is that when i hover over the stacks, there's no way to find out which year i'm hovering over (unless you look at the legend). Reason for this is because the 'Legend' field cannot be populated since i'm bringing in 3 calculated measures. 

How would i dynamically display the year i'm hovering over? 

I  tried some If and SWITCH statements but it returns the same year across all 3 stacks. 


For more context, there is also a report level slicer and based on the financial year that is selected, the stacked bar chart should always show selected year as well as previous 2 years. 


1 REPLY 1
amitchandak
Super User
Super User

@Andrea_Jess ,Two ways I can think of. One is calculation group.

 

Another one, Create a 3 year measure based on selected year and independent table and use year as legend

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = year(maxx(allselected(Date1),Date1[Date]))
var _min =  _max -2
return
calculate( sum(Table[Value]), filter('Date', 'Date'[year] >=_min && 'Date'[year] <=_max))

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.