Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Meme123
New 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 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%)

 

Meme123_1-1675308516775.png


Any help appreciated! 

 

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

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)

Samarth_18_0-1675316143039.png

 

 

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

View solution in original post

6 REPLIES 6
Samarth_18
Community Champion
Community Champion

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)

Samarth_18_0-1675316143039.png

 

 

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

TomasAndersson
Solution Sage
Solution Sage

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.

TomasAndersson
Solution Sage
Solution Sage

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!

 

Meme123
New Member

I should have noted that '#Classes changed' and '#All classes' are from two different tables. 

wdx223_Daniel
Super User
Super User

Percentage%=DIVIDE([# Classes Canged],[# ALL classes],0)

Sorry, I should have noted that '#Classes changed' and '#All classes' are from two different tables. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.