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
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
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.

Top Solution Authors
Top Kudoed Authors