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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Carlos_Ponce
Frequent Visitor

Can`t put legends in a two measures stacked bar chart

Hi, I have a chart with two measures, one with positive and other with negative values, like this

Carlos_Ponce_0-1650889218361.png

And the problem is that I can't put the legends of the different items so that each bar is split in differents colors, something like this (I had to put two different charts to do that)

 

Carlos_Ponce_1-1650889340359.png

 

When I have only one measure in the chart i can put legends, but not when I have two measures.

Thanks a lot

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @Carlos_Ponce ,

 

You cannnot have legends and more than one measure on the visualizations is one of the limitations, for this to work you would need to have a table with a MGI or using calculation groups so you would have the measures on the calculation and the values on the legends.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Hi @Carlos_Ponce ,

 

MGI is Mother-Generated Index calculation meaning that you would have a table similar to this:

 

Index Measure
1 Measure 1
2 Measure 2
3 Measure 3
4 Measure 4

 

Then using a Switch metric you would pull each metric for the visualization.

 

Similar to:

 

Metric Value =

SWITCH (
    SELECTEDVALUE ( Table[Index] ),
    1, [Measure 1],
    2, [Measure 2],
    3, [Measure 3],
    4, [Measure 4]
)

 

 

Now if you use the Column on the table on top for the Legend and the Measure to the values you get multiple measures with legend.

 

It seems to me that you have a variable number of values that will be picked up base on a categorization or something similar, that will be a lot of values and not a small number so would be doable but maybe hard coding a little.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

7 REPLIES 7
GregGiamz
Helper I
Helper I

GregGiamz_0-1715673177759.png

Hi all, I've tried the above method which works.
However, I'm looking to add one more Type (legend or if any other field works).
Would it be possible? 

Eg. 
Category 1 - Metric 1 - Type a or b
Category 1 - Metric 2 - Type a or b
Category 1 - Metric 3 - Type a or b
Category 1 - Metric 4 - Type a or b
Category 1 - Metric 5 - Type a or b

Hi @GregGiamz ,

 

For this you need to add an hierarchy to the Axis level if the type is a column that is part of your model you just need to add both of then you can drill up and down at each level of the axis.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Appreciate your reply!

I understand what you mean, however, we are looking to have it on the stacked chart like this, instead of multiple hierarchy drill down on the axis level:
would you know if this is possible:

GregGiamz_0-1715675513358.png

 

Hi @GregGiamz ,

 

Not sure if I understood how you have the data, can you please share a sample data and expected result please.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi @Carlos_Ponce ,

 

You cannnot have legends and more than one measure on the visualizations is one of the limitations, for this to work you would need to have a table with a MGI or using calculation groups so you would have the measures on the calculation and the values on the legends.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix thanks a lot for the answer.

Im a little new in this, what dos it mean table whith MGI? I searched in internet but didnt find it.

Hi @Carlos_Ponce ,

 

MGI is Mother-Generated Index calculation meaning that you would have a table similar to this:

 

Index Measure
1 Measure 1
2 Measure 2
3 Measure 3
4 Measure 4

 

Then using a Switch metric you would pull each metric for the visualization.

 

Similar to:

 

Metric Value =

SWITCH (
    SELECTEDVALUE ( Table[Index] ),
    1, [Measure 1],
    2, [Measure 2],
    3, [Measure 3],
    4, [Measure 4]
)

 

 

Now if you use the Column on the table on top for the Legend and the Measure to the values you get multiple measures with legend.

 

It seems to me that you have a variable number of values that will be picked up base on a categorization or something similar, that will be a lot of values and not a small number so would be doable but maybe hard coding a little.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.