Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamically including columns in stacked column chart

Hi all! 

 

I have an input table of the format:

 

DateCategory ACategory B
01/01/20201221
01/02/2020117
01/03/2020445

 

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:

DateKategories ACategory BCategory C
01/01/2020122199
01/02/202011732
01/03/20204452

 

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.

  • Anonymous's avatar
    Anonymous
    6 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,
    Kelly
    Did I answer your question? Mark my post as a solution!

     

4 Replies

  • 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.

  • Anonymous's avatar
    Anonymous
    Not 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,
    Kelly
    Did I answer your question? Mark my post as a solution!

     

  • Anonymous's avatar
    Anonymous
    Not 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:

     

    DateKategories ACategory BCategory CSales (never want it to be included)
    01/01/202012219934
    01/02/20201173212
    01/03/202044521

     

    • Anonymous's avatar
      Anonymous
      Not 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,
      Kelly
      Did I answer your question? Mark my post as a solution!