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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Need assistance with writing a measure

Hello,

 

Pretty much, I have two fields of data that I'm trying to connect through a measure and determine the difference between two totals that are categorized by a code. For example:

 

Field 1                                             

Code         Amount

ABC             100

DEF              200

GHI              300

 

Field 2               

Code         Amount

ABC             50

DEF             100

GHI             150

 

In my actual data, both "Code" lines are linked via the relationship manager, but when I write a measure subtracting the respective Amounts, I don't get the correct answer. I should be getting ABC = 50, DEF = 100 and GHI = 150 if I'm creating a measure to subtract the amounts by Code.

 

Can someone please help me as to what I should be writing as a measure to correctly subtract the two? Thank you for your help.

1 ACCEPTED SOLUTION
sayaliredij
Super User
Super User

You can create measure using the following code

 

Diff = SUM(Field1[amount]) - SUM(Field2[amount])

 

Make sure Code from both tables connected with relationship both directional

 

Regards,

Sayali

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
sayaliredij
Super User
Super User

You can create measure using the following code

 

Diff = SUM(Field1[amount]) - SUM(Field2[amount])

 

Make sure Code from both tables connected with relationship both directional

 

Regards,

Sayali

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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