Reputation: 43
I have two custom columns at the end of the query named "Total" and "GST", the "Total" column sums columns "Storage", "PltHire", "Admin", "InActivity", "OutActivity", "Add Activity", "Freight", "Packaging" and "Other". While the "GST" Column is 10% of the "Total" Column, I have used the round function in power query and set it to 2 decimal places and for some reason the "GST" column is not rounding correctly. If you review the image it shows that the highlighted row has $154.25 which power query has rounded to $15.42 this should actually round to $15.43. I'm not sure if I have done anything that I need to before hand so if anyone can help me that would be great and if you need anymore information please let me know.
Note - what I found odd was that when I created another custom column for the total column which added the total and gst ([total]*1.1 instead of [total]*0.1) that column was able to round correctly?
Thanks!
I have tried to change the M code by using the following but to no avail.
Upvotes: 1
Views: 4538
Reputation: 1
Ken Puls discussed this back in Sep 2014:
I do not think it has been fixed so Ken's article is still valid.
You will want to use RoundingMode.AwayFromZero if you want to match how Exel handles rounding:
=Number.Round([Value],2,RoundingMode.AwayFromZero)
Upvotes: 0
Reputation: 40264
There isn't a uniform consensus on rounding 0.5. In fact, rounding to the even (Power Query default) is less biased than rounding up. Fortunately, the Power Query Number.Round
function allows for different rounding styles as the optional 3rd argument.
You likely want Number.Round([Custom],2,0)
or, equivalently, Number.Round([Custom],2,RoundingMode.Up)
but you have the following options as well:
RoundingMode.Down
(or 1
)RoundingMode.AwayFromZero
(or 2
)RoundingMode.TowardsZero
(or 3
)RoundingMode.ToEven
(or 4
) [default]Upvotes: 2