cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Super User

## Display up to two decimal but not by rounding

Hi,

Is there a way Power Query can display Decimal Numbers up to 2 decimal point and not achieve this task by rounding.

For example, if the value is 1.2368, I want to see 1.23 so that when I compare this value with another column that contains 1.23 too, the subtraction should result a 0.

I tried doing this by using Number.Round. So it rounds 1.2368 to 1.24 and when I compare it with another column containing 1.23 there is a difference of 0.01.

Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
Super User

Try this:

```let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQzMjYxNVOK1QGzzcwtLGFsI0tLIDsWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Number = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", type text}}),
#"Extracted First Characters" = Table.TransformColumns(#"Changed Type", {{"Number", each Text.Start(_, 4), type text}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Extracted First Characters",{{"Number", type number}})
in
#"Changed Type1"```

Basically, convert to text. Extract first 4 characters, then convert back to a decimal number. Presto, chango, truncate without rounding.

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
7 REPLIES 7
Super User

Try this:

```let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQzMjYxNVOK1QGzzcwtLGFsI0tLIDsWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Number = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", type text}}),
#"Extracted First Characters" = Table.TransformColumns(#"Changed Type", {{"Number", each Text.Start(_, 4), type text}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Extracted First Characters",{{"Number", type number}})
in
#"Changed Type1"```

Basically, convert to text. Extract first 4 characters, then convert back to a decimal number. Presto, chango, truncate without rounding.

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Frequent Visitor

Hi @Greg_Deckler this is a great solution - exactly what im looking for however as Im a bit of a power bi novice can you please alloborate on where/how you use this solution? Many thanks 🙂

Super User

Thanks @Greg_Deckler. It worked for me.

Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

CAN U SHARE HOW U SOLVED

@smpa01 wrote:

Thanks @Greg_Deckler. It worked for me.

Super User

Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Super User

Hi @smpa01,

In the modeling tab you can define what is the number of decimals you want to see in your decimal numbers just select 2, this is also achievable in each of the visuals by selecting the formating option in the data setup.

This can be used for columns or measures.

Regards,

MFelix

Regards

Miguel Félix

Proud to be a Super User!

Check out my blog: Power BI em Português

Super User

Thanks @MFelix for the response. I was looking for possible solution if exists in Power Query. Nonetheless I wanted to try it out the way you advised. But it did not yield what I was looking for.

Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors