Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Tiphany01
Frequent Visitor

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.

Tiphany01_0-1621005216412.png

And eventually the graph would look like this:

Tiphany01_1-1621005264207.png

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

Tiphany01_2-1621005319647.png

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?

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community 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:

v-henryk-mstf_1-1621238456428.png

v-henryk-mstf_2-1621238471223.png

 

v-henryk-mstf_0-1621238389531.png

 


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.

View solution in original post

4 REPLIES 4
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..

Hi @Tiphany01 ,

 

For columns from multiple tables, the above results may not be achieved through unpivot. Refer to the similar solution below.Solved: Multiple unpivot in one table - Microsoft Power BI Community

Best Regards,
Henry

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

v-henryk-mstf
Community Support
Community 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:

v-henryk-mstf_1-1621238456428.png

v-henryk-mstf_2-1621238471223.png

 

v-henryk-mstf_0-1621238389531.png

 


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.

amitchandak
Super User
Super User

@Tiphany01 , for that you have to unpivot the table and then use the new column as axis.

https://radacad.com/pivot-and-unpivot-with-power-bi

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.