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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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