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
LuukP
Helper I
Helper I

Subtracting two equal measures gives wrong result

Hi everyone,

 

I have a strange situation where I am subtracting two variables of equal value and they provide the wrong result.  (Note that when the two variables are different amounts, the subtraction works correctly.)

 

Here is a screenshot of the New Card Visual showing the data being returned for a specific employee with the wrong result highlighted:

LuukP_0-1695223794308.png

Here is the measure for the Other calculation:

LuukP_2-1695223929540.png

 

Each measure is exactly the same data type (Decimal number with 2 decimal points.  If I change to more than 2 decimal points, they still return 2 decimal points e.g. 155.350 so it's not a data type issue.)

 

Any idea what is going wrong here?

 

Thanks in advance!

 

Luuk

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@LuukP Looks like a floating point/accuracy kind of issue. Perhaps try changing the data type from Decimal to Fixed? Or add a check that if value is less than .0000000000001 or something and if so return 0.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

rsbin
Super User
Super User

@LuukP ,

Expand your Measures to 18 decimal places and I believe you may see the difference.

To get around this, use the ROUND function in your Measures to actually round your  values to 2 decimal places, rather than just "display" 2 decimal.

Hope this helps resolve your issue.

Regards,

View solution in original post

3 REPLIES 3
LuukP
Helper I
Helper I

@Greg_Deckler @rsbin Thanks for your responses.  Rounding the two variables solved the issue.

rsbin
Super User
Super User

@LuukP ,

Expand your Measures to 18 decimal places and I believe you may see the difference.

To get around this, use the ROUND function in your Measures to actually round your  values to 2 decimal places, rather than just "display" 2 decimal.

Hope this helps resolve your issue.

Regards,

Greg_Deckler
Super User
Super User

@LuukP Looks like a floating point/accuracy kind of issue. Perhaps try changing the data type from Decimal to Fixed? Or add a check that if value is less than .0000000000001 or something and if so return 0.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.