Forum Discussion
How to create a multi-tiered percentage-based bar chart?
Hello,
I would like to create a multi-tiered percentage-based bar chart based on the data found below (test data evidently). Column B and C add up to 100%, Column D and E add up to 100%, and lastly column F and G add up to 100%. I would like each set of variables to equate to 100% on the graph, as the source data is percentage based anyways, but all be organized in their own separate row on the graph underneath the employee name. I have included a diagram drawn in MS paint to portray the desired output (with an accompanying legend). Thanks in advance!
| Employee Name | Number of Sales Made % | Number of Sales Made from Other Competitors % | Number of Calls Made % | Number of Calls Made from Other Competitors % | Number of Individual Employees % (always is 1) | Number of competitor employees % |
| John | 28.57% | 71.43% | 30.00% | 70.00% | 16.67% | 83.33% |
| Stacy | 41.67% | 58.33% | 38.71% | 61.29% | 20.00% | 80.00% |
| Richard | 47.06% | 52.94% | 47.06% | 52.94% | 14.29% | 85.71% |
| Andy | 42.31% | 57.69% | 40.48% | 59.52% | 10.00% | 90.00% |
6 Replies
- LorenzoSilver Contributor
Another Power Query option that makes the chart more readable:
File (to download) available at:
https://1drv.ms/x/c/1cd824d35610aacb/IQAdKE5z--lsR4BVrh7bA833AfxBO6fTeCWY3ogM3-mTAvc?e=KuP6feEDIT: Trying to attach file...
- PeterBartholomew1Silver Contributor
The essential characteristic of the replies you have received is that the data needs to be unpivoted in order to plot it. This can be done using PowerQuery or by formula.
= LET( wrapped, WRAPROWS(TOCOL(data),2)/100, name, TAKE(WRAPROWS(TOCOL(IF(data, Tabelle1[Employee])),2),,1), hdr, TAKE(WRAPROWS(TOCOL(IF(data, header)),2),,1), HSTACK(name, hdr, wrapped) )If you include the attribute names in the chart data then the presentation can be labelled more meaningfully.
- IlirUIron Contributor
Hi,
In cell I2 I have applied this formula:
=HSTACK(TEXTSPLIT(TEXTJOIN("",, REPT(A2:A5 & ",", COLUMNS(B2:G5) / 2)),, ",", TRUE), WRAPROWS(TOCOL(B2:G5), 2))I then selected cells I2:K13 and in the Insert Chart window I chose Bar (see the screenshot above).
Hope this helps.
IlirU
- LorenzoSilver Contributor
Hi
A 365 dynamic option. With your data formatted as table named Table1 in the below formula:
=LET( data, Table1, colsCount, COLUMNS( data ), fieldsCount, colsCount -1, names, TOCOL( IF( SEQUENCE(, fieldsCount/2), CHOOSECOLS(data, 1) ) ), values, WRAPROWS( TOCOL( CHOOSECOLS(data, SEQUENCE(fieldsCount,,2) ) ), 2 ), VSTACK( {"Employee name", "value 1", "value 2"}, HSTACK( names, values ) ) ) - OliverScheurichGold Contributor
I've applied Power Query to convert the blue table into the green result table. In the attached file you can add data to the blue dynamic table. Then you can click in any cell of the green table and right-click with the mouse and select refresh to update the green result table. The stacked bar chart is updated dynamically.
- nkpCopper Contributor
This works, thank you for your efforts!