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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
shanestocks
Helper I
Helper I

Weird Rounding Error

Hi all, wanting to perform a very, very simple comparison with the following:

 

shanestocks_0-1709571247282.png

In the "Overuse" column the top record is showing 716 but that's not correct. The DAX is:

 

= ([Usage (KG)] - [Req (KG)]) * [Act. (EUR)]. The top then, (12,544 - 12,392) * 4.744 = 721.

 

Can I ask how on earth this isn't working please? The [Act. (EUR)] calculation is:

 

=VAR weightedPrice = SUMX(fUsage,fUsage[req_qty] * fUsage[meat_price])
VAR reqTotal = sum(fUsage[req_qty])

RETURN

ROUND(DIVIDE(weightedPrice,reqTotal),3)

 

The raw data is:

 

order_numberproductionreq_qtyusage_qtydate_of_productionp_codemeat_codestandard_pricemeat_price
3105638990880281004/12/2023P10000RM00234.984.605
3105669546040640507/12/2023P10000RM00234.984.605
3105698791981281811/12/2023P10000RM00234.984.605
3105731688578278014/12/2023P10000RM00234.984.605
3105763891981283118/12/2023P10000RM00234.984.605
3105773545440140019/12/2023P10000RM00234.984.605
3105826146040640527/12/2023P10000RM00234.984.605
3105887144839640503/01/2024P10000100826334.984.98
31059168675596599.506/01/2024P10000RM00234.984.605
3105932813171163117008/01/2024P10000100826334.984.98
3105996285175276013/01/2024P10000RM00234.984.605
3106009985175276515/01/2024P10000100826334.984.98
3106069013621203120020/01/2024P10000RM00234.984.605
3106112991981281024/01/2024P10000RM00234.984.605
3106140313221168120027/01/2024P10000100826334.984.98
3106188212801131118531/01/2024P10000100826334.98

4.98

 

Thank you so much

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

12,544 is not the real value.  It's a rounded display value.  That's what I tried to guide you to with my previous answer.

The real sum is 12543.50.

Subtracting 12392 from 12543.50 equals 151.5.  This could be rounded to 151 or 152 .  Multiply those values by 4.98 and you get close to 752 and 757.  So that explains what you're seeing.  And, as before, the Overuse measure is being displayed as a whole number so it's being rounded for display purposes.

--

So what to do about it? First, look at the display format of each measure. Click on the measure in the data pane (on  the right) and the MeasureTools ribbon appears. Look at the Format section.  Powerbi makes assumptions here with data type (and decimal places, if applicable).  You can over-ride these choices.  Remember, this is for display.  The 'real' values are held behind the scenes. 

In your case, the display values have been rounded for display and that's leading to confusion.

 

 

View solution in original post

3 REPLIES 3
HotChilli
Super User
Super User

12,544 is not the real value.  It's a rounded display value.  That's what I tried to guide you to with my previous answer.

The real sum is 12543.50.

Subtracting 12392 from 12543.50 equals 151.5.  This could be rounded to 151 or 152 .  Multiply those values by 4.98 and you get close to 752 and 757.  So that explains what you're seeing.  And, as before, the Overuse measure is being displayed as a whole number so it's being rounded for display purposes.

--

So what to do about it? First, look at the display format of each measure. Click on the measure in the data pane (on  the right) and the MeasureTools ribbon appears. Look at the Format section.  Powerbi makes assumptions here with data type (and decimal places, if applicable).  You can over-ride these choices.  Remember, this is for display.  The 'real' values are held behind the scenes. 

In your case, the display values have been rounded for display and that's leading to confusion.

 

 

HotChilli
Super User
Super User

There's plenty of scope for rounding issues due to the number of different measures involved.

Item 1 for investigation :   Usage (kg) in the visual = 12544.

but there's a 599.5 value in the data so something's been rounded there.

 

Hi HotChilli thank you for response. So to avoid this what can I best do? The DAX I use merely contains the calculations, but in the visual display I am choosing "whole number", so I am not rounding anything up, but something is definitely amiss and I simply cannot find it. 

 

The only DAX I am using for this calculation is 3 measures:

 

[Total Usage]

 

=SUM(fUsage[usage_qty])

 

[REQ (KG)]

 

=SUM(fUsage[req_qty])

 

ACTUAL COST [Act. (EUR)] - (This returns weighted average)

 

=VAR weightedPrice = SUMX(fUsage,fUsage[req_qty] * fUsage[meat_price])
VAR reqTotal = sum(fUsage[req_qty])

RETURN

ROUND(DIVIDE(weightedPrice,reqTotal),3)

 

OVERUSE (EUR)

 

=([Total Usage]-[Req (KG)])*[Act. (EUR)]

 

Interestingly, I also get the same issue when using the standard price which is a fixed value...

 

shanestocks_0-1709629747668.png

 

(12,544-12,392) * 4.980 = 757, not the 752 shown.

 

Any help would be greatly appreciated, I have spent many days on this and cannot find a solution.

 

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Users online (944)