Forum Discussion
Stacked column chart with dynamic legend
- 1 year ago
Hi Justas4478 ,
Thank you for the update and for trying the suggested option. The custom visual may not fully match Excel’s dynamic legend alignment because Power BI’s visuals, both native and custom, don’t replicate this feature exactly. The best way to achieve similar behaviour is by reshaping your data model using Unpivot Columns and then creating the stacked column chart as previously described. This setup allows the legend to update dynamically with filters, which addresses your main requirement. Although the result may not look exactly like Excel, it is currently the most reliable and supported method in Power BI.
If you need a closer match, you could explore other visuals in AppSource, but the unpivot and stacked column chart remains the most consistent and flexible solution.
Thank you,Tejaswi.
Hi Justas4478 ,
You can easily create a stacked column chart with a dynamic legend in Power BI by making a few adjustments to your data. Here’s how you can do it:
- Import your data into Power BI (Home → Get Data → Excel/CSV).
- Open Transform Data (Power Query).
- Select your difference columns (such as Diff1, Diff2, Diff3).
- Right-click and select Unpivot Columns. This will generate two new columns: one for the difference type (e.g., Diff1, Diff2, Diff3) and one for the values.
- Rename these columns (for example, “Difference Type” and “Amount”), then choose Close & Apply.
- Add a Stacked Column Chart visual.
- Assign StorageType to the Axis, Difference Type to the Legend, and Amount to the Values.
With this setup, your legend will dynamically update when filters are applied, just like in Excel. For a table below the chart, simply add a Matrix visual using StorageType as rows, Difference Type as columns, and Amount as values. This approach will deliver the results you need.
I’ve attached the .pbix file and screenshots for your reference.
Thank you,
Tejaswi.
- v-tejrama1 year agoCommunity Support
Hi Justas4478 ,
I wanted to follow up and see if you had a chance to review the information shared. If you have any further questions or need additional assistance, feel free to reach out.
Thank you.
- Justas44781 year agoPost Prodigy
I tried the proposed custom visual form visual store unfortuantelly it does not function as I was hoping.
I will try to see maybe I can find other solutions.- v-tejrama1 year agoCommunity Support
Hi Justas4478 ,
Thank you for the update and for trying the suggested option. The custom visual may not fully match Excel’s dynamic legend alignment because Power BI’s visuals, both native and custom, don’t replicate this feature exactly. The best way to achieve similar behaviour is by reshaping your data model using Unpivot Columns and then creating the stacked column chart as previously described. This setup allows the legend to update dynamically with filters, which addresses your main requirement. Although the result may not look exactly like Excel, it is currently the most reliable and supported method in Power BI.
If you need a closer match, you could explore other visuals in AppSource, but the unpivot and stacked column chart remains the most consistent and flexible solution.
Thank you,Tejaswi.