# Truncate in Power Query

• ### Question

• Is there a way to consider only the first 2 decimal cases in power query?

Ex: I have 4286,0679 and I want 4286,06.

Thanks

Thursday, April 23, 2015 1:58 PM

• As far as I can tell, there's a function for rounding but not for truncation:

Number.Round(4286.0679, 2)
4286.07

Here's a function that implements truncation:

Number.Truncate = (number, digits) => Int64.From(number * Number.Power(10, digits)) / Number.Power(10, digits)

Thursday, April 23, 2015 3:29 PM

### All replies

• As far as I can tell, there's a function for rounding but not for truncation:

Number.Round(4286.0679, 2)
4286.07

Here's a function that implements truncation:

Number.Truncate = (number, digits) => Int64.From(number * Number.Power(10, digits)) / Number.Power(10, digits)

Thursday, April 23, 2015 3:29 PM
• Workaround-solution would be to split this field by ","-delimiter.

Then Text.Start(DecimalField,2): will deliver your 2 digits.

Concatenate back.

Imke

Thursday, April 23, 2015 7:51 PM
• There only seems to be a function for the special case of truncating the result of an integer division:

Number.IntegerDivide(num, divisor, Precision.Decimal)

Specifying the precision as Precision.Decimal is necessary to avoid bad surprises based on floating point idiosyncrasies.