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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
alierm
Regular Visitor

Changing data type to fixed decimal number incorrectly rounds up number

Hi
I have a column with long decimal values. When I change the data type of that column from decimal number to fixed decimal number, values getting rounded up in a wrong way. For example:
0.25085000000000002 after conversion becomes 0.2509 while
0.25085 after conversion becomes 0.2508.
Could someone explain how does it work?
Thanks in advance

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User
2 REPLIES 2
AlienSx
Super User
Super User

ManuelBolz
Responsive Resident
Responsive Resident

Hello @alierm,

 

this is a common problem in almost all IT systems or software solutions. Rounding large numbers often leads to problems.

In my solution I wrote you a function. You can adapt this function to your needs. This allows you to define your own “rounding logic”.

Please get in touch if you have any questions.


Custom function:
1) In Power Query
2) Create a new Query

3) Paste this Code

4) Rename the Query to "fnCustomRound"

(RoundNumber as number, DecimalPlaces as number) as number =>
let
    Multiplier = Number.Power(10, DecimalPlaces),
    ScaledNumber = RoundNumber * Multiplier,
    RoundedNumber = if Number.Abs(ScaledNumber - Number.RoundDown(ScaledNumber)) >= 0.5
                    then Number.RoundUp(ScaledNumber)
                    else Number.RoundDown(ScaledNumber),
    Result = RoundedNumber / Multiplier
in
    Result


In your Data Query:
1) Add the following Code

 ColumnCustomRounded = Table.AddColumn(#"NAME OF THE PREVIOUS STEP", "RoundedColumn", each fnCustomRound([#"NAME OF YOUR DECIMAL COLUMN"], 4))



Best regards from Germany
Manuel Bolz


If this post helped you, please consider Accept as Solution so other members can find it faster.

🤝Follow me on LinkedIn

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (894)