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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
0Experience
Helper I
Helper I

Dynamic Legend and Line Chart Comparison

Hi everyone,

 

I’m working on a Power BI report and facing a few challenges I’d love your input on.

 

I have data spanning from 2018 to 2023, with three types for each year: Type-1Type-2, and Type-3. I’ve created a new combined type called Type-12, which merges Type-1 and Type-2. Each type also has data for five different locations.

 

I want to build a column chart that dynamically updates based on a slicer selection:

  • If I select Type-1, the chart should show only Type-1 values.
  • If I select Type-12, it should display a stacked column combining Type-1 and Type-2.
  • The chart uses separate measures for each type.

The issue:

Even when I select only Type-1 or Type-12, the legend still shows all measures (Type-1, Type-2, Type-3, Type-12), because they’re used in the Y-axis. I want the legend to reflect only the selected types from the slicer.

 

Also, I’m using both Year and Type on the X-axis, which is necessary for my layout, but it’s making the legend labels too long and cluttered (see screenshot). Is there a way to simplify or hide part of the legend without losing the dual-axis structure?

 

0Experience_0-1754931169604.png

 

 

Line chart:

I also have a line chart comparing Type-1 and Type-12. Since each type has 3 location points per year, I end up with 6 points per year (3 for each type), which makes sense. But visually, it’s hard to compare the two types clearly. Is there a better way to structure this line chart for easier comparison?

 

I have attached power bi file , and any suggestions or workarounds would be greatly appreciated!

 

3 REPLIES 3
v-dineshya
Community Support
Community Support

Hi @0Experience ,

Thank you for reaching out to the Microsoft Community Forum.

 

Please provide expected output snap.  It will easy for us to replicate the issue.

 

Regards,

Dinesh

Greg_Deckler
Community Champion
Community Champion

@0Experience Create a relationship between your two tables. Then use a standard count measure, just:

Measure = COUNTROWS( 'Test_Data_Table' ) and put that in your Y-axis instead of all of your other measures. Put type column in your Legend. If necessary, you can account for type 12 in your single measure using an IF statement like:

Measure =
    IF (
        "type-12" IN VALUES('type_sort'[type]),
            CALCULATE(
                COUNTROWS(Test_Data_Table),
                FILTER( ALL( Test_Data_Table ), Test_Data_Table[type] = "type-1")
            ),
            COUNTROWS( Test_Data_Table )
    )

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hello @Greg_Deckler 

 

Thanks for your prompt reply and your suggestions. But this will not help me. As I need stacked column for type 1 and type 2 (not a single column). See the screenshot please

 

0Experience_0-1754932693415.png

 

Even if I put my type column in legend it is not fulfiling my purpose. 

 

0Experience_1-1754932807370.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors