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
GarethWoodhouse
Resolver I
Resolver I

Subracting measures and getting the wrong answer

I have created 2 measures that are working wonderfully.

 I now need to subtract one from the other so I created a third measure:
Hardware GP2 = 'Measures 1'[Hardware Sales] - 'Measures 1'[Hardware GP]
 
When I display the output I can see that the subtract isn't working and the calculated figure is incorrect..
Any one have any ideas what is happening here?
Thanks.
 
measuresubtract.png
 
1 ACCEPTED SOLUTION

I think I have found the problem. At some point through the calculations, the signage of one of the figures is being swapped. In the final measure both input values are shown as a negative (hence the incorrect value is being calculated vs the expected value), however pre input one of these values should be a positive.

I will now step through the calculations to pin point exactly what is going on here.

 

Many Thanks to you all for confirming that the DAX should work which ruled this out for me as a variable.

View solution in original post

8 REPLIES 8
cleopas5
New Member

Hello Experts, i am calculating the difference between two columns based on row values. But the difference is slightly off. Column 1 is Sales actual and column 2 is Plan cost

 

Sales Actual-Plan = [Sales Actual] - ['Year Plan'[Plan Cost]

 

Sales Actual                Plan Cost                   Sales Actual - Plan Cost

1,335,121                      3,947,194                  -2,611,985 wrong supposed to be -2,612,073

1,692,710                       6,557,214                   -4,864,504. correct

1,188,426                       3,154,451                     -1,966,013 wrong supposed to be -1,966,025

.

.

.

Total 

33,144,323                       116,599,970                 -83,205,650 wrong supposed to -83,455,647

 

Not sure what is going on here. Please any help will be greatly appreciated 

 

 

AlB
Super User
Super User

Hi @GarethWoodhouse

What is it that you are showing in the capture? A matrix visual?

Can you share the pbix file?

I know it isn't helpful but I can not share the PBX in this instance because of the data.

 

Yes - It's an adulterated matrix view to show whats going on.

 

I have validated both measures feeding this final subtration measure and to that point everything is correct.

Both figures feeding in are correct, however the result is not.

@GarethWoodhouse

 

What's the code for the other two measures? With this amount of info you leave us a bit in the dark.

Maybe you can share a mock pbix with just dummy data but showing the issue?  I guess if this is not very time-consuming   

Measures Below.
Sales and GP are creating the correct figures.
 
Hardware Sales = Calculate(sum('Management Accounts'[Amount]),Filter('Management Accounts','Management Accounts'[MAHeaderID]=10 && 'Management Accounts'[MASectionID] = 10))
 
 
Hardware GP = calculate(SUM('Management Accounts'[Amount]),filter('Management Accounts','Management Accounts'[MAHeaderID]=20 && 'Management Accounts'[MASectionID]=10))
 
 
Hardware GP2 = 'Measures 1'[Hardware Sales] - 'Measures 1'[Hardware GP]
 
 
 

HI, @GarethWoodhouse

I have tested on my side, all these three measure work well. there should be some other problem caused the wrong answer.

Could you please use some simple simulated data to do a pbix file and share it with the expected output.

 

 

Best Regards,

Lin

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

I think I have found the problem. At some point through the calculations, the signage of one of the figures is being swapped. In the final measure both input values are shown as a negative (hence the incorrect value is being calculated vs the expected value), however pre input one of these values should be a positive.

I will now step through the calculations to pin point exactly what is going on here.

 

Many Thanks to you all for confirming that the DAX should work which ruled this out for me as a variable.

Anonymous
Not applicable

What answer are you hoping for?  Looks like from here that if you subtract those two figures, you get the total.  Generally the issues with totals is one of filters, or lackthereof. 

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.