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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Help Calculating School Performance Index in Power BI (Complicated Calculation in Power BI)

Hi Friends, 

 

I am trying to calculate a school and district's "Performance Index" in Power BI. 

 

1) Calculate the percentage of tests in each subject that fall into a given performance level (limited, proficient, advanced).

2)Assign points based on the percentage of tests in each performance level. (For example, advanced is worth 2 points, proficient is worth 1, and limited is worth 0.5. A school with 50% of students in the Limited category, 30% of students in the Proficient category, and 20% of students in the Advanced category would earn 95 points, because (50 x 0.5)+(30 x 1) + (20 x 2) = 95 points.)

 

My data is formatted as follows 

student_idsubjectschool_yearperformance_level
1234Math2022Limited
1234Reading2022Proficient
5678Math2022Advanced
5678Reading2022Proficient
1357Math2022Limited
1357Reading2022Limited

 

There will be multiple school years in this file as well - this is a simplified view. 

 

How would I approach this in Power BI? Would it be best to do this in PowerQuery somehow, or would it be better to create a measure in DAX? A mixture of both? 

 

PowerBI is not something I frequently use and am very much a beginner, so I appreciate any help you can provide!

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please new two measures:

 

percentage = 
VAR _count = COUNTROWS('Table') + 0
VAR _total = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[subject],'Table'[school_year]))
VAR _percentage = DIVIDE(_count,_total)
RETURN
_percentage
points = 
VAR _subject= MAX('Table'[subject])
VAR _year = MAX('Table'[school_year])
VAR _Advanced = SUMX(FILTER('Table','Table'[subject]=_subject&&'Table'[school_year]=_year&&'Table'[performance_level]="Advanced"),[percentage])+0
VAR _Proficient = SUMX(FILTER('Table','Table'[subject]=_subject&&'Table'[school_year]=_year&&'Table'[performance_level]="Proficient"),[percentage])+0
VAR _Limited = SUMX(FILTER('Table','Table'[subject]=_subject&&'Table'[school_year]=_year&&'Table'[performance_level]="Limited"),[percentage])+0
VAR _Point = (_Advanced*2+_Proficient+_Limited*0.5)*100
RETURN
_Point

 

vcgaomsft_0-1665382930091.png

 

M or DAX? That is the Question

KNP's answer:

When should I favor DAX over PowerQuery for perfor...

Comparing DAX calculated columns with Power Query computed columns

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

3 REPLIES 3
v-cgao-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please new two measures:

 

percentage = 
VAR _count = COUNTROWS('Table') + 0
VAR _total = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[subject],'Table'[school_year]))
VAR _percentage = DIVIDE(_count,_total)
RETURN
_percentage
points = 
VAR _subject= MAX('Table'[subject])
VAR _year = MAX('Table'[school_year])
VAR _Advanced = SUMX(FILTER('Table','Table'[subject]=_subject&&'Table'[school_year]=_year&&'Table'[performance_level]="Advanced"),[percentage])+0
VAR _Proficient = SUMX(FILTER('Table','Table'[subject]=_subject&&'Table'[school_year]=_year&&'Table'[performance_level]="Proficient"),[percentage])+0
VAR _Limited = SUMX(FILTER('Table','Table'[subject]=_subject&&'Table'[school_year]=_year&&'Table'[performance_level]="Limited"),[percentage])+0
VAR _Point = (_Advanced*2+_Proficient+_Limited*0.5)*100
RETURN
_Point

 

vcgaomsft_0-1665382930091.png

 

M or DAX? That is the Question

KNP's answer:

When should I favor DAX over PowerQuery for perfor...

Comparing DAX calculated columns with Power Query computed columns

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Anonymous
Not applicable

Wow, thank you so much for the help with this! I do have one question -- what is the reason for adding a zero at the end of the SUMX calculations? Is it so it doesn't return an error in the case of a null/blank value?

aj1973
Community Champion
Community Champion

Hi @Anonymous 

Power Query is best for ETL, DAX is best for calculations.

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.