Forum Discussion

Tiphany01's avatar
Tiphany01
Frequent Visitor
5 years ago
Solved

Stacked Bar Graph (Pivot and unpivot) query

Hi Everyone,

 

I have the below tabluar data and I have to build a simple stacked bar graph based on this.

And eventually the graph would look like this:

However, I would like to represent the graph in the below format but not able to achieve it in PowerBI.

The difference between the two charts are basically the axis.(Name of measure columns in X-axis and dimension shown as stacked).
Could you advise on how to bring about the second view, please?

  • Hi Tiphany01 ,

     

    In Powerbi Desktop, the x-axis field in visual must come from the same column value. If you need to convert to the above visual, you first need to unpiovt column in Powerbi query, convert the four categories to the same column, and then add the corresponding field to the Stacked Bar visual. The reference is as follows:

     

     


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

    Best Regards,
    Henry

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Icon for Community Support rankCommunity Support

    Hi Tiphany01 ,

     

    In Powerbi Desktop, the x-axis field in visual must come from the same column value. If you need to convert to the above visual, you first need to unpiovt column in Powerbi query, convert the four categories to the same column, and then add the corresponding field to the Stacked Bar visual. The reference is as follows:

     

     


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

    Best Regards,
    Henry

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Tiphany01's avatar
    Tiphany01
    Frequent Visitor

    Thank you amitchandak  and v-henryk-mstf  for the detailed steps. But in my requirment the dimension column (here: Domain) and the measure columns are being sourced from two different tables. In such a scenario, I don't think we can apply the unpivot right? Could you advise what to do then..