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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Stacked bar chart formatting

Hi guys,

 

Looking for suggestions on how to approach this, I created a stacked chart which contains similar legends but different values, i needed them to be stacked in a cronological order, for this i created an index for each for the values, so far looks like this:

edgarcalgary_0-1598649033634.png

as you can see under State column the string values repeat several times, but the chart is stacking them by index, is there a way i can keep the current alignment in the chart but apply specific colors to each of the unique State values? as you can see the word "Static" repeats like 7 times, however the chart provides 7 different colors to that value and i am aiming to get one color only.

 

thanks for any suggestions.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

category.PNG

 

Steps:

 

1. Add a calculated column.

 

Legend = [Category] & [Index]

 

le.PNG

 

2. Create a table to sort Category in reverse order. Or just use "enter data" to set custom order.

 

Category = 
VAR t =
    DISTINCT ( 'Table'[Category] )
RETURN
    ADDCOLUMNS ( t, "Order", RANKX ( t, [Category],, DESC, DENSE ) )

 

ca.jpg

relation.jpg

 

3. Create a measure.

 

1 = 1

 

 

4. Create visuals.

  • Create a Ribbion visual and change the data color manually, then turn off background.

ribbon visual.gif

changetitle.PNG

  • Create a Treemap visual.

treemap.gif

 

  • Create a text box and enter text "Legend".
  • Group.

group.gif

 

Best Regards,

Icey

 

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

8 REPLIES 8
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try to use Ribbon Chart inteading of Stacked Column Chart.

ribbon.gif

 

Reference: Ribbon Chart is the Next Generation of Stacked Column Chart

 

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

@Icey , thanks for your answer,

 

would be a way to order this by index but only showing unique legend? my problem right now is when aggregating values as i do not need to aggregate nothing but showing the results in cronological order.

 

Thanks for any guide.

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

category.PNG

 

Steps:

 

1. Add a calculated column.

 

Legend = [Category] & [Index]

 

le.PNG

 

2. Create a table to sort Category in reverse order. Or just use "enter data" to set custom order.

 

Category = 
VAR t =
    DISTINCT ( 'Table'[Category] )
RETURN
    ADDCOLUMNS ( t, "Order", RANKX ( t, [Category],, DESC, DENSE ) )

 

ca.jpg

relation.jpg

 

3. Create a measure.

 

1 = 1

 

 

4. Create visuals.

  • Create a Ribbion visual and change the data color manually, then turn off background.

ribbon visual.gif

changetitle.PNG

  • Create a Treemap visual.

treemap.gif

 

  • Create a text box and enter text "Legend".
  • Group.

group.gif

 

Best Regards,

Icey

 

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

DataInsights
Super User
Super User

@Anonymous, try this:

 

1. Create a States table.

 

DataInsights_0-1598715670702.png

 

2. Join States table to Fact table.

 

DataInsights_1-1598715700079.png

 

3. In Data view, click on States[State] column and sort by Index.

 

4. In chart, Legend should be States[State].

 

DataInsights_2-1598715718257.png

 





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

Proud to be a Super User!




Anonymous
Not applicable

Thanks @DataInsights  thats a huge lead,

I will start applying it now, just one more question, so because the state will be changing, for example not alwasy ream up will be the first in the secuence, for example now i have another set of data with HR 20, with different secuence than 19, would this logic would work? the most important part here is to follow the secuence in the secuence for each HR value but providing a specific color for each of the unoique values in states:

 

 

example_chart.PNG

 

 

@Anonymous,

 

Would you be able to provide a mock-up of how you want each HR (19 and 20) to look in the chart?





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

Proud to be a Super User!




Anonymous
Not applicable

@DataInsights , i created this using python,

edgarcalgary_0-1598737597890.png

 

however this is not guided by index, here is a bit easier but the script takes wayy too long, so for example in HR 19, the secuence is the following:

edgarcalgary_1-1598737684857.png

where ream up is 1,  Wash out 2 and on, on HR 20 the secuence is:

edgarcalgary_2-1598737756574.png

where now 1 is rotate drill and 2 ream up, the problem i am facing is that the secuence only works when i out index as legend but each value has a color whereas i need a color for only the uniques. : ( 

 

@Anonymous,

 

I'm not sure how to dynamically change the stack order of each column (may not be possible without a workaround). From what I can see, the first portion of the left column (HR 19) is the largest value (In Slips), and therefore subsequent columns (HR 20) put In Slips as the first portion of the column. This appears to be standard behavior, and I don't see any option to override it.

 

DataInsights_0-1598742056664.png

 

One last thought--you could browse the custom visuals to see if there's a chart that offers this functionality.





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

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.