Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Why does Power Bi change the % decimal places?

Our ERP system brings in this column like the 1st screen shot.   Gross margin = 57.29 but notice it brings it in as a text field.   If I convert that column to a percentage type, it makes the margin ...
  • v-kelly-msft's avatar
    5 years ago

    Hi Anonymous ,

     

    First go to query editor and change the column type to number,then using below M code:

     

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjXXM7I0NFOKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type number}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Column1]>0 and [Column1]<100 
    then Number.ToText([Column1])&"%"
    else[Column1])
    in
        #"Added Custom"

     

     

    And you will see:

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

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