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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ross27
Advocate II
Advocate II

Rounding x.5 to 0 decimal places and converting to text

When I round a number to zero decimal places and then convert to text I get a suprious ".0" added to any values that end in .5

 

For example:

 

let
   Input = 12.5,
   Output = Text.From(Number.Round(Input))
in
   Output

 

Returns "12.0" rather than "12"

 

I can fix my output easily enough, but could someone please explain why this happens? 

2 REPLIES 2
artemus
Employee
Employee

Number.Round has a second parameter which takes the number of decimal places. As a result this returns a number which in its base form is floating point. You can use Int64.From(x) to convert a floating point number to an integer based number

Thanks @artemus .  That's what I've ended up doing, but I don't really see why I have to.  Even when I specify 0 as the second parameter I end up with a number that is shown to 1dp.   Wouldn't you expect Number.Round to take care of this itself?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors