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
CarlosDaniel
Regular Visitor

Power BI Column Series Issue in Stacked Bar Chart

Hello guys, I want to do a Stacked Bar Chart that looks like this:

CarlosDaniel_0-1683829851441.png

 

Each month have two stacked bars, the first one is the ideal result and the second one is the real result. Each stack is a cell that creates a certain ammount of products.

1. The data for the months stand alone are static values provided by the user, but the "Month" + .Planned data should be a dynamic value depending of the value of a Slicer (Parameter).

2. I should be able to filter with slicers through other features: Division --> Department --> Product and in the stacked bar charts should be displayed only the cells that fits this conditions.

 

My problem is, I haven't be able to display the stacked columns. I already have the slicers working, the chart shows both bar charts but Power BI doesn't allow me to add a Column Series. I've tried a lot of things but anything seems to work.

 

Let me share with you some dummy data to work with:

 

ScenarioDivisionDepartmentProductCellJanJan.PlannedFebFeb.PlannedMarMar.Planned
IdealX1Dep1P1Cell1 6 6 6
IdealX1Dep1P1Cell2 7 1 5
IdealX1Dep2P2Cell3 9 8 9
IdealX1Dep2P2Cell4 8 2 6
IdealX2Dep3P3Cell5 4 10 5
IdealX2Dep3P3Cell6 5 6 7
IdealX2Dep4P4Cell7 5 3 5
IdealX2Dep4P4Cell8 7 1 10
RealX1Dep1P1Cell15 1 8 
RealX1Dep1P1Cell26 2 9 
RealX1Dep2P2Cell37 2 2 
RealX1Dep2P2Cell48 5 7 
RealX2Dep3P3Cell59 3 10 
RealX2Dep3P3Cell67 10 10 
RealX2Dep4P4Cell75 4 10 
RealX2Dep4P4Cell82 10 10 

 

IMPORTANT: This table was splitted in two, one containing only the "Real" Scenario data and another for the "Ideal" Scenario data.

 

This is the visualization I already have:

CarlosDaniel_1-1683830300047.png

 

I can not place the "Cell" field in the "Column Series Field"

CarlosDaniel_2-1683830411062.png

 

The ideal and real fields are the following measures:

Ideal = SUM(IdealTable[Value]) + (Parameter[Parameter Value] * 2)

Real = SUM(RealTable[Value])

 

The Month field have two columns, the first one holding all the Months + Months.Planned and the second column an Index column to order the months from Jan to Dec.Planned. All this fields are related to each other. That's why I don't know the reason I can't add the "Cell" field to the Column Series of the stacked bar + line chart.

 

CarlosDaniel_3-1683831032788.png

 

 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @CarlosDaniel 

According to your description, you want to put the [Cell] to the Legend .

Thanks for your sample data first~I test it in my side and i found that when we put one more fields on the Y-axis , we may can not put other fields on the Lgend.

(1)We need to create a new dimension table and we do not need to create any relationship between other tables.

Row = {"Real","Ideal"}

vyueyunzhmsft_0-1684131865119.png

(2)Then we can create a measure like this:

Measure = 
 var _row = MAX('Row'[Value])
 return
 IF(_row="Ideal" && SUM(IdealTable[Value]), 
SUM(IdealTable[Value]) + (Parameter[Parameter Value] * 2),IF(_row="Real",SUM(RealTable[Value])))

 

Then we can put the measure on the visual and we can get this:

vyueyunzhmsft_1-1684131920125.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @CarlosDaniel 

According to your description, you want to put the [Cell] to the Legend .

Thanks for your sample data first~I test it in my side and i found that when we put one more fields on the Y-axis , we may can not put other fields on the Lgend.

(1)We need to create a new dimension table and we do not need to create any relationship between other tables.

Row = {"Real","Ideal"}

vyueyunzhmsft_0-1684131865119.png

(2)Then we can create a measure like this:

Measure = 
 var _row = MAX('Row'[Value])
 return
 IF(_row="Ideal" && SUM(IdealTable[Value]), 
SUM(IdealTable[Value]) + (Parameter[Parameter Value] * 2),IF(_row="Real",SUM(RealTable[Value])))

 

Then we can put the measure on the visual and we can get this:

vyueyunzhmsft_1-1684131920125.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

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.