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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
igalav2021
New Member

Substracting in matrix

Hello all,

I'm new to this community and hope you can assist with something I'm struggling with. 

After filtering exam dates (see table below), I want to be able to show the difference between the scores of each exam and each section, so then I can filter only the sections in which there was a change in score. 

igalav2021_0-1639481886564.png

I tried to follow some ideas that were shared here before, but couldn't find something that I fully understand and that worked. Can someone please assist? Thank you!!

 

9 REPLIES 9
bcdobbs
Community Champion
Community Champion

Are you able to share a demo PBIX file with your basic table structure and some dummy data. This is by far the easiest to work with.

 

Alternaively a picture of your data model and example of data in each table



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Thanks for the swift response. 

I understand that the screenshot is not sufficient? 

I can't share the PBIX (corporates confidential information), but created a dummy data sheet. let me know if this helps. 

Student IDExam DateExam NumberSectionScore
11111127/11/202015120
11111127/11/202015260
11111127/11/202015320
11111127/11/202016115
11111127/11/202016245
11111127/11/20201630
22222227/11/202015110
22222227/11/202015250
22222227/11/202015325
22222227/11/202016120
22222227/11/202016245
22222227/11/202016315
11111103/12/20211510
11111103/12/202115250
11111103/12/202115320
11111103/12/202116115
11111103/12/202116260
11111103/12/202116325
22222203/12/202115110
22222203/12/202115270
22222203/12/202115320
22222203/12/202116120
22222203/12/202116245
22222203/12/202116330

I hope this is clearer now.

Great. And you're looking at differences for each student?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

for each student, and for each exam section. I want to flag only the sections that had score changes. (comparing the same exam number and sections with 2 different dates, flaging the sections with score changes). 

Just to highlight that the dates are filtered. there are more test dates with more values.

Using your data and column names importing it as a table called Result I first wrote this measure:

Score Comparison = 
    VAR EarliestDate = FIRSTDATE( Result[Exam Date] )
    VAR LatestDate = LASTDATE( Result[Exam Date] )

    VAR EarliestScore = 
        CALCULATE(
            SUM(Result[Score]),
            EarliestDate
        )
    
    VAR LatestScore = 
        CALCULATE(
            SUM(Result[Score]),
            LatestDate
        )

    RETURN 
    IF(
        HASONEVALUE(Result[Exam Date]), 
        SUM(Result[Score]),
        LatestScore - EarliestScore
    )

 

Then put that measure into a matrix:

bcdobbs_0-1639486865572.png

 

 

 

 

 

 

bcdobbs_2-1639486925052.png

Lastly if you go into the subtotal section of the matrix formating you can change "Total" to read "Difference"

bcdobbs_1-1639486904061.png

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Unfortunately, it doesn't work. 

It gives back 0 as the results for all the rows: 

igalav2021_0-1639488500509.png

igalav2021_1-1639488650648.png

 

Few questions:

In your version do you just have a single table like the data you sent?
Are Weight and Weighted Score just extra columns?
Presumably you've modified the dax I sent to match your structure. Can your modified version back and I'll see if I can spot the issue.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Thank you for your support!! I double-checked and indeed I made a mistake 🙂 

There are indeed more columns that I didn't mention. Basically, each exam section has a different weight. 

Your solution works. However, the outcome shows the score comparison column for each date and the Difference (the subtotal) shows the calculation for all columns and not only for the Raw Score. I want to avoid showing unnecessary columns that might confuse the user. Any thoughts? 

bcdobbs
Community Champion
Community Champion

There are other options where you could use two disconnect tables from which to select dates but the basic idea remains the same.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.