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.
Hello,
I'm fairly new to PowerBi and struggling with adding in calculated columns. I need to add a column (in the value field in this matrix table) that claculates the percentage of '#classes changes' against '#all classes'. So the first row should equal 2.36% (462 classes changed out of a total of 19521 classes is 2.36%)
Any help appreciated!
Solved! Go to Solution.
Hi @Meme123 ,
You could create a measure as below and format it as percentage:-
Percentage_classes = DIVIDE(sum('table1'[# Classes Changed]),Sum('table2'[# ALL classes]),0)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi @Meme123 ,
You could create a measure as below and format it as percentage:-
Percentage_classes = DIVIDE(sum('table1'[# Classes Changed]),Sum('table2'[# ALL classes]),0)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Another easy way, if you don't need it to be a calculated column and are ok with a measure (that can be shown as a column in a matrix) could just be to calculate the sum for each and then divide them:
Percentage :=
DIVIDE(
SUM([# Classes Changed]),
SUM([# All Classes])
)
It might depend on how your data is structured, but a possiblity.
Hi!
If # Classes Changed and # All Classes are from different tables you can use LOOKUPVALUE() first.
You need some sort of common key for each class in your tables (called ClassKey below, change accordingly). This also assumes that you create the columns in your table with the All Classes (ACTable) value and not the table with Classes Changed (CC Table). You can do it the other way around, but need to switch up the DAX then.
Then a calculated column should be able to look something like this:
% changed =
VAR __CurrentClass =
ACTable[ClassKey]
VAR __ClassesChanged =
LOOKUPVALUE(CCTable['# Classes Changed'],CCTable[ClassKey], __CurrentClass)
VAR _
return
DIVIDE(
__ClassesChanged,
ACTable['# All Classes'])
Good luck!
I should have noted that '#Classes changed' and '#All classes' are from two different tables.
Percentage%=DIVIDE([# Classes Canged],[# ALL classes],0)
Sorry, I should have noted that '#Classes changed' and '#All classes' are from two different tables.
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 |
---|---|
46 | |
26 | |
21 | |
12 | |
8 |
User | Count |
---|---|
75 | |
52 | |
45 | |
15 | |
12 |