Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I'm creating a couple of matrices in Power BI and I'm trying to create one that has counts by a certain stat and the other will show the percentage. It was easy enough to get the counts (see below). However, I'm having a hard time creating percentages. What I want to do is show the percent of Used or Unused by Fiscal Year by Scholarship Type. So the Unused % for Awareness for FY15 would be 15% and Used would be 85%. How would I go about doing it? I'm fairly new to BI so apologies if this is something simple.
FY15 | FY16 | ||||||
Scholarship Type | Unused | Used | Total | Unused | Used | Total | Grand Total |
Awareness | 19 | 108 | 127 | 57 | 461 | 518 | 645 |
Partner | 69 | 686 | 755 | 124 | 1081 | 1205 | 1960 |
Recognition | 88 | 554 | 642 | 61 | 616 | 677 | 1319 |
Regulator | 20 | 280 | 300 | 79 | 382 | 461 | 761 |
Also, here's how the underlying table in the data model is structured
Scholarship Recipient ID | Usage Stats | Fiscal Year | Scholarship Type |
4529783 | Used | FY15 | Recognition |
10564207 | Used | FY16 | Recognition |
6409092 | Used | FY16 | Recognition |
30748898 | Used | FY15 | Recognition |
17522706 | Used | FY16 | Recognition |
18329306 | Used | FY16 | Partner |
17310161 | Used | FY15 | Recognition |
21357211 | Used | FY16 | Awareness |
Solved! Go to Solution.
In a Matrix, the columns are generated based on column group data fields which is dynamic. We can't directly have one column divide by another column.
In your scenario, you need to limit the scope for current row context in your calculations. You can create two measures, one for Unused, the other for Used. Then calculate the percentage based on the those two measures.
Unused Total= CALCULATE(SUM(Table[Value]),FILTER(Table,Table[Usage Status]="Unused"))
Used Total= CALCULATE(SUM(Table[Value]),FILTER(Table,Table[Usage Status]="Used"))
Used Pct= [Used Total]/([Unused Total]+[Used Total])
Unused Pct= [Unused Total]/([Unused Total]+[Used Total])
Regards,
Simon Hou
Add index column to your data model and then user that column for count.
step 1: click edit query
step 2 : add index column
and this is how it will show in your data model, you can change the header label whatever you want
and change all formulas from sum to count like this:
Unused Total= CALCULATE(COUNT(Table[Index]),FILTER(Table,Table[Usage Status]="Unused"))
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.
In a Matrix, the columns are generated based on column group data fields which is dynamic. We can't directly have one column divide by another column.
In your scenario, you need to limit the scope for current row context in your calculations. You can create two measures, one for Unused, the other for Used. Then calculate the percentage based on the those two measures.
Unused Total= CALCULATE(SUM(Table[Value]),FILTER(Table,Table[Usage Status]="Unused"))
Used Total= CALCULATE(SUM(Table[Value]),FILTER(Table,Table[Usage Status]="Used"))
Used Pct= [Used Total]/([Unused Total]+[Used Total])
Unused Pct= [Unused Total]/([Unused Total]+[Used Total])
Regards,
Simon Hou
Unfortunately this didn't work. The Usage Stats column in the underlying table is a text field.
Error Message: MdxScript(Model) (1, 62) Calculation error in measure 'ScholarshipData'[Unused Total]: The function SUM takes an argument that evaluates to numbers or dates and cannot work with values of type String.
Add index column to your data model and then user that column for count.
step 1: click edit query
step 2 : add index column
and this is how it will show in your data model, you can change the header label whatever you want
and change all formulas from sum to count like this:
Unused Total= CALCULATE(COUNT(Table[Index]),FILTER(Table,Table[Usage Status]="Unused"))
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.
Thanks to both of you!
Thank you! I will try this out when I get back to work next week. Appreciate the response.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |