Forum Discussion
Stacked bar chart formatting
- 6 years ago
Hi Anonymous ,
Try this:
Steps:
1. Add a calculated column.
Legend = [Category] & [Index]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 ) )3. Create a measure.
1 = 14. Create visuals.
- Create a Ribbion visual and change the data color manually, then turn off background.
- Create a Treemap visual.
- Create a text box and enter text "Legend".
- Group.
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, try this:
1. Create a States table.
2. Join States table to Fact table.
3. In Data view, click on States[State] column and sort by Index.
4. In chart, Legend should be States[State].
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:
- DataInsights6 years agoSuper User
Anonymous,
Would you be able to provide a mock-up of how you want each HR (19 and 20) to look in the chart?
- Anonymous6 years agoNot applicable
DataInsights , i created this using python,
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:
where ream up is 1, Wash out 2 and on, on HR 20 the secuence is:
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. : (
- DataInsights6 years agoSuper User
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.
One last thought--you could browse the custom visuals to see if there's a chart that offers this functionality.