Forum Discussion
Meme123
3 years agoNew Member
Adding in a calculated column - percentage
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 cha...
- 3 years ago
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)
TomasAndersson
Solution Sage
3 years agoHi!
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!