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
alicito1802
New Member

Create a transposed table from an existing table

I have the following table with 10 KPI but I am struggling to make a bar chart and an stacked bar chart with it, I did a manual table and found the solution that allow me to plot the data and get my chart. But I need to do it using DAX or in any automated manner so it updates automatically when refreshed.

 

To be able to plot the data I need to create a new table that transform this:

 

alicito1802_0-1696530383201.png

 

Into this

alicito1802_1-1696530454195.png

Could you kindly offer one solution?

Kind regards

 

1 ACCEPTED SOLUTION

I solved like this:

Copied the original table.

In the copied table selected the 10 KPI columns and unpivot them.

Renamed The Attribute Colum to KPI

Clicked “Create New table” in the data model and used the summarize function as follow:

SummarizedRAG =

SUMMARIZE(

     'DB (3)',

     'DB (3)'[KPI],

     "RedCount", COUNTROWS(FILTER('DB (3)','DB (3)'[Value]="Red")),

     "AmberCount", COUNTROWS(FILTER('DB (3)','DB (3)'[Value]="Amber")),

     "GreenCount", COUNTROWS(FILTER('DB (3)','DB (3)'[Value]="Green"))

)

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@alicito1802 It is pretty straightforward, you don't need to unpivot and pivot data:

 

- transform data -> select all columns -> right click -> Unpivot columns

 

You will get two columns, attribute and value, rename these as you wish. close and apply

 

To visualize, take a matrix visual: add attribute on rows, value on columns, and count of value on value section of matrix visual and you will get the result you need.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I solved like this:

Copied the original table.

In the copied table selected the 10 KPI columns and unpivot them.

Renamed The Attribute Colum to KPI

Clicked “Create New table” in the data model and used the summarize function as follow:

SummarizedRAG =

SUMMARIZE(

     'DB (3)',

     'DB (3)'[KPI],

     "RedCount", COUNTROWS(FILTER('DB (3)','DB (3)'[Value]="Red")),

     "AmberCount", COUNTROWS(FILTER('DB (3)','DB (3)'[Value]="Amber")),

     "GreenCount", COUNTROWS(FILTER('DB (3)','DB (3)'[Value]="Green"))

)

kiran_jadhav
Frequent Visitor

Hello Alicito,
You can achive this using few transformation in Power query.

1. Remove the Promoted Headers  step from Applied steps. 

2. Select all the colums and Transpose.

3.Rename 1st column to KPI.

4. Select the KPI column and click on  Unpivot other Columns.
5.
Select KPI & Value  column and  Remove Other Column.
6.Duplicate the KPI column.
7. select Value Column & Pivot it. (select KPi column as values).

You will have your desired result.
I have attached the screenshot for your referance.

1.png

2.png

3.png

4.png

5.png

6.png

  

7.png

 
 

 

 

 
 

 



Thanks for your reply Jadhav, it kind of worked but the numbers dont add up, for the HSE column I should be getting 25 green and one amber.

 

alicito1802_1-1696572577167.png

And I am getting 34 gree and 1 amber

alicito1802_0-1696572503954.png

 

kiran_jadhav
Frequent Visitor

Hello Alicito,

You can use power query for that
1. Go to transform Data
2. Go to transform tab, Now select all three colum of your data  i.e Red, Amber, Green.
3.Under "Any column" section you will find Unpivot column. click on Unpivot colum.
4. now your data will be divided to 3 three columns KPI, Attribute & Values.
5. you can rename Attribute and values column as per your need.

I hope this will be helpfull. 

 

@kiran_jadhav The problem is to change the data in first image to data in second image.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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