Forum Discussion
Dynamically including columns in stacked column chart
Hi all!
I have an input table of the format:
| Date | Category A | Category B |
| 01/01/2020 | 12 | 21 |
| 01/02/2020 | 11 | 7 |
| 01/03/2020 | 4 | 45 |
From which I create a stacked column chart with Date on the x-axis, and Category A & Category B stacked on-top of each other.
However, if a user makes a change to the source table (e.g. changes the name of one of the categories and adds a new one) how can I still capture this in a stacked column chart? i.e. dynamically add/subtract/change stacked columns
Example of change:
| Date | Kategories A | Category B | Category C |
| 01/01/2020 | 12 | 21 | 99 |
| 01/02/2020 | 11 | 7 | 32 |
| 01/03/2020 | 4 | 45 | 2 |
I would in this case want the stacked column chart to show Date along x-axis and Kategories A, Category B, and Category C to be stacked. Without having to manually alter the visual.
Any suggestions to allow for this are welcome!
Thank you.
- Anonymous6 years ago
Hi Anonymous ,
Yes,you should unpivot all the category columns into one column that it will automatically apply for the changes:
Steps are as below:
Go to query editor>select category columns>unpivot:
And you will see:
For the related .pbix file,pls click here.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
4 Replies
- parry2kSuper User
Anonymous you should unpivot your data
- transform data
- select date column in your table
- right-click, unpivot other columns it will add two columns, attribute, and value, rename these as per your requirement
- close and apply
To visualize,
- date on x-axis- attribute on legend
- value on values section
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- AnonymousNot applicable
Hi Anonymous ,
Yes,you should unpivot all the category columns into one column that it will automatically apply for the changes:
Steps are as below:
Go to query editor>select category columns>unpivot:
And you will see:
For the related .pbix file,pls click here.
Best Regards,
KellyDid I answer your question? Mark my post as a solution! - AnonymousNot applicable
Hi Anonymous parry2k thank you very much for your suggestions. However, in the case where I only have some columns that I would want to include and others that I wouldn't; how could I approach this?
As an example please see the table below:
Date Kategories A Category B Category C Sales (never want it to be included) 01/01/2020 12 21 99 34 01/02/2020 11 7 32 12 01/03/2020 4 45 2 1 - AnonymousNot applicable
Hi Anonymous ,
It doesnt matter,when you are unpivoting columns,you just need to select the column you need,like below:
You would find that sales column wasnt unpivoted.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!