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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to achieve this in PowerQuery?

Hello, 

 

There is a requirement for me to do calculations in PowerQuery end which I am not sure.

 

KarthikKV_0-1628840753676.png

How to do a calculation from here as 444/166 which is 2.67. I can do this easily in DAX but please do let me know how to achieve in PowerQuery?

 

A column name with Ratio with a value of 2.67.

 

Thanks,

Karthik

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

HI @Anonymous ,

 

I am considering you are having only two records in your table. You can apply below steps:-

image.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k3MK03MUdJRMjExUYrViVbyy89T0FXIhQkbmpkpxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Job Category" = _t, Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Job Category", type text}, {"Count", Int64.Type}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Manual", Int64.Type}, {"Non - manual", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [Manual] / [#"Non - manual"]),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Added Custom", {"Custom"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Job Description"}, {"Custom", "count"}}),
    #"Renamed Columns1" = Table.RenameColumns(#"Renamed Columns",{{"Value", "counts"}, {"count", "Divide"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns1",{"Job Description", "counts", "Divide"})
in
    #"Reordered Columns"

I have added data using enter data you can update source based on your source.

Samarth_18_0-1629008980087.png

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

HI @Anonymous ,

 

I am considering you are having only two records in your table. You can apply below steps:-

image.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k3MK03MUdJRMjExUYrViVbyy89T0FXIhQkbmpkpxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Job Category" = _t, Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Job Category", type text}, {"Count", Int64.Type}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Manual", Int64.Type}, {"Non - manual", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [Manual] / [#"Non - manual"]),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Added Custom", {"Custom"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Job Description"}, {"Custom", "count"}}),
    #"Renamed Columns1" = Table.RenameColumns(#"Renamed Columns",{{"Value", "counts"}, {"count", "Divide"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns1",{"Job Description", "counts", "Divide"})
in
    #"Reordered Columns"

I have added data using enter data you can update source based on your source.

Samarth_18_0-1629008980087.png

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Thank you so much @Samarth_18 . Though it seems to be lot of steps in PowerQuery but seems to be achievable. Thanks for your guidance.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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