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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
HNil
Frequent Visitor

Dynamic legend in stacked area chart

Hi,

 

I'm strugling to understand how to implement dynamic variables to my stacked area chart. I've tried looking at different solutions, but I can't comprehend how to apply it to my own data. 

 

My data table consist of the following table from Excel:

 

SectorYearCostsTech A reductionsTech B reductionsTech C reductionsTech D reductions
Farms2025500-15-10  
Farms2027515-35-50  
Fishing20251500  -60-100
Fishing20271525  -150-120

 

In my stacked area chart, I want to be able to have a slicer that toogles "Farms" or "Fishing". But if I select only "Farms" for instance, I only want the legends for Tech A and Tech B to be visible, since all the numbers from the two "Fishing"-related columns aren't present in the visual anyways (except for their legends, that are cluttering my visual).

 

In my stacked area chart, I have "Year" on the X-axis and "Costs" & "Tech A-D" on the Y-axis.

 

Any help is greatly appreciated. Apologies if this has been asked before, but I couldn't get other solutions to work for me.

 

Best regards

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You do that by bringing your source data into a usable format. The process is called unpivoting.

 

From 

lbendlin_0-1695501050905.png

to 

lbendlin_1-1695501145091.png

From there your legend issues resolve themselves.

View solution in original post

2 REPLIES 2
HNil
Frequent Visitor

Thanks Ibendin, for making that clear to me.

 

The solution was indeed to unpivot the cost-column and the technology columns.

lbendlin
Super User
Super User

You do that by bringing your source data into a usable format. The process is called unpivoting.

 

From 

lbendlin_0-1695501050905.png

to 

lbendlin_1-1695501145091.png

From there your legend issues resolve themselves.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.