cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
smpa01
Super User
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.

 

Thank you in advance.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






New Animated Dashboard: Sales Calendar


1 ACCEPTED SOLUTION
Greg_Deckler
Super User
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.


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
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.


@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Learn Power BI 2nd Edition

Thanks @Greg_Deckler. It worked for me.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






New Animated Dashboard: Sales Calendar


Anonymous
Not applicable

CAN U SHARE HOW U SOLVED


@smpa01 wrote:

Thanks @Greg_Deckler. It worked for me.


 

@Anonymousyou can follow the solution





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






New Animated Dashboard: Sales Calendar


MFelix
Super User
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.

 

format.png

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.

 

 

Capture.PNGCapture 1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






New Animated Dashboard: Sales Calendar


Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors