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

View all the Fabric Data Days sessions on demand. View schedule

Reply
ONCKdata
Helper I
Helper I

Sum of selected rows in a Matrix

Hello All,

I have a table of students and their marks across subjects and tests:

PBI 1.PNG 

I have created a matrix in PowerBI as below:

PBI 2.PNG

 

Now, I want to add a custom row in matrix that gives sum of Geometry and Algebra marks, kindly help me.

 

Thanks.

1 ACCEPTED SOLUTION
quentin_vigne
Solution Sage
Solution Sage

 

Hi @ONCKdata

 

A simple solution came into my mind : 

Create a new column "Category"

 

Category = IF(OR(YourTable[Subject]="Geometry";YourTable[Subject]="Algebra");"Science";"Others")

Add it to the lines of your matrix and expand it to the level where it looks like that : 

 

matrix.PNG

 

- Quentin

View solution in original post

3 REPLIES 3
quentin_vigne
Solution Sage
Solution Sage

 

Hi @ONCKdata

 

A simple solution came into my mind : 

Create a new column "Category"

 

Category = IF(OR(YourTable[Subject]="Geometry";YourTable[Subject]="Algebra");"Science";"Others")

Add it to the lines of your matrix and expand it to the level where it looks like that : 

 

matrix.PNG

 

- Quentin

Hi,

Thank you very much for the reply.

 

Your solution solves the question I have asked, but can you tell me if there is way to mention difference of two rows?

 

 

@ONCKdata

 

To make a difference between two rows is very tricky and complicated, this is why I don't do it (example here : https://community.powerbi.com/t5/Desktop/How-to-calculate-difference-between-two-row-values/td-p/389...)

 

What I prefer to advice is to pivot / unpivot the needed rows so that they became column and can be comparable with a simple '-' 

 

 

- Quentin

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors