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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shreyansh008
Regular Visitor

Subtracting Rows ( subtracting Rows Values from Same column based on value from another table)

Hello Experts,

 

I am trying to create calucated column using DAX Function where i am trying to subtract different subject score based on User ID. 

I have three table, Table1 contain candidate User ID information, Table2 contain Score and Subject ID,and Table3 contain Subject name and Subject ID. Table structure are below :

Table1
ID1User ID
1A
2B
3C
4D
Table2
ID1Subject IDScore
1A123
2A234
2A121
1A243
1A332
Table3
Subject IDSubject
A2English
A1Maths
A3Science
A4History

 

 

I am trying to create DAX Column below :

 

 ABDAX Column
Maths2321SQRT(23-21)
English4334SQRT(43-34)

 

How can i create Calculated column (DAX Column)? Please Help

 

Thanks

 

 

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @shreyansh008 , 

You could refer to my sample for details.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
dax
Community Support
Community Support

Hi @shreyansh008 , 

You could refer to my sample for details.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Microsoft Employee
Microsoft Employee

I am not sure about the calculation you are trying to do and how you plan to visualize it.  Assuming you have a 1:Many between Table 3 and Table 2, you could calculate the square root of the difference between the max and min score for each subject with this DAX expression:

 

SqrtMaxMin = 

var maxscore = calculate(max(Table2[Score])

var minscore = calculate(min(Table2[Score])

var difference = maxscore-minscore

return sqrt(difference)

 

If that is not right, maybe you can adapt that to meet your needs.  Note the the Calculate() is key to create context transition (i.e., use the Subject on Table 3 as a filter for the calculation on Table 2).

 

If this works for you, please mark it as the solution.  Kudos are great too.  Please let me know if it doesn't or if any questions.
Regards,
Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.