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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Michael1
Advocate II
Advocate II

Calculating a Weighted Performance using DAX

Hello Power BI Community,

 

I am trying to calculate a weighted measure where the result is a single value.

 

This is student assessment data where there are four possible levels that a student might have achieved (beginning, devloping, proficient or distinguished) where each of these levels needs to be weighted (beginning=0, developing=0.5, proficient=1.0, distinguished=1.5).

 

To accomplish this (without DAX), I simply determine the number of students at each level and then multiply them by the value (above) and lastly divide by the number of students assessed.

 

To complicate this formula--I have duplicate records, so I need to filter by performance level and by a distinct Student ID.

 

If you are willing, please take a look at the code below and offer suggestions.

 

Bmk 2 Retest 4 5 ES Weighted Performance =
VAR Beginning =
    CALCULATE (
        COUNTROWS ( 'Bmk 2 Retest 4 5 ES' ),
        FILTER ( 'Bmk 2 Retest 4 5 ES', DISTINCT ( 'Bmk 2 Retest 4 5 ES'[StudentID] ) ),
        FILTER (
            'Bmk 2 Retest 4 5 ES',
            'Bmk 2 Retest 4 5 ES'[performance_level] = "Beginning"
        )
    )
VAR Developing =
    CALCULATE (
        COUNTROWS ( 'Bmk 2 Retest 4 5 ES' ),
        FILTER ( 'Bmk 2 Retest 4 5 ES', DISTINCT ( 'Bmk 2 Retest 4 5 ES'[StudentID] ) ),
        FILTER (
            'Bmk 2 Retest 4 5 ES',
            'Bmk 2 Retest 4 5 ES'[performance_level] = "Developing"
        )
    )
VAR Proficient =
    CALCULATE (
        COUNTROWS ( 'Bmk 2 Retest 4 5 ES' ),
        FILTER ( 'Bmk 2 Retest 4 5 ES', DISTINCT ( 'Bmk 2 Retest 4 5 ES'[StudentID] ) ),
        FILTER (
            'Bmk 2 Retest 4 5 ES',
            'Bmk 2 Retest 4 5 ES'[performance_level] = "Proficient"
        )
    )
VAR Distinguished =
    CALCULATE (
        COUNTROWS ( 'Bmk 2 Retest 4 5 ES' ),
        FILTER ( 'Bmk 2 Retest 4 5 ES', DISTINCT ( 'Bmk 2 Retest 4 5 ES'[StudentID] ) ),
        FILTER (
            'Bmk 2 Retest 4 5 ES',
            'Bmk 2 Retest 4 5 ES'[performance_level] = "Distinguished"
        )
    )
VAR NumberAssessed =
    CALCULATE (
        COUNTROWS ( 'Bmk 2 Retest 4 5 ES' ),
        FILTER ( 'Bmk 2 Retest 4 5 ES', DISTINCT ( 'Bmk 2 Retest 4 5 ES'[StudentID] ) )
    )
RETURN
    CALCULATE (
        ( ( beginning * 0 )
            + ( developing * 0.5 )
            + ( proficient * 1.0 )
            + ( distinguished * 1.5 ) )
            / NumberAssessed
    )

 

When I try to display the measure in a Card I receive this error:

couldn't load data.png

 

Your help is greatly appreciated,

 

Michael

1 ACCEPTED SOLUTION
Mi2n
Microsoft Employee
Microsoft Employee

Instead of trying to use Distinct() within in the Filter() function, can you try to use it directly inside the Countrows() function like,

 

COUNTROWS ( DISTINCT ( 'Bmk 2 Retest 4 5 ES'[StudentID] ))

 

Let me know if this helps.

 

Oh, and why do you even calculate the value for Beginning if it is gonna be multiplied with zero ? Smiley Wink 

View solution in original post

5 REPLIES 5
Mi2n
Microsoft Employee
Microsoft Employee

Instead of trying to use Distinct() within in the Filter() function, can you try to use it directly inside the Countrows() function like,

 

COUNTROWS ( DISTINCT ( 'Bmk 2 Retest 4 5 ES'[StudentID] ))

 

Let me know if this helps.

 

Oh, and why do you even calculate the value for Beginning if it is gonna be multiplied with zero ? Smiley Wink 

This works great!  Thank you.

Mi2n
Microsoft Employee
Microsoft Employee

Just a small update. Instead of both the CountRows() and Distinct() function, the single Countdistinct() function will also work. 

DISTINCTCOUNT works great!  Thanks -- I guess I just needed to switch the way I was trying to think about this.

 

Thank you again :)!

Mi2n
Microsoft Employee
Microsoft Employee

Oops! forgot the function name. Smiley Embarassed

 

Good that you got it anyway.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.