The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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:
Into this
Could you kindly offer one solution?
Kind regards
Solved! Go to 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"))
)
@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"))
)
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.
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.
And I am getting 34 gree and 1 amber
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.
User | Count |
---|---|
77 | |
75 | |
36 | |
31 | |
29 |
User | Count |
---|---|
94 | |
80 | |
55 | |
48 | |
48 |