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
numersoz
Helper III
Helper III

Row to Column Transformation

I have data in below format:

 

DateAsset IDValue
1/1/2022150
1/2/2022255
1/3/2022360
1/4/2022465


I would like to transform this table below:

 

A common date column, but each asset having its own column.  Any tips? Either as a calculated table or via Power Query.

 

DateAsset 1Asset 2Asset 3Asset 4Value
1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @numersoz 

 

Is this an output you are looking for?

VahidDM_0-1642628664769.png

 

 

if yes, in Power Query select Asset and Value and use pivot column.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckksSVXSUXIsLk4tUfB0ATLDEnNKU5VidaKVDPUN9Y0MjIyAgoZAbGoAFTWCiYKwqSlU1BgmagzEZjC1JjBRE5AoUG0sAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Asset ID", Int64.Type}, {"Value", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type1", {{"Asset ID", type text}}, "en-AU"), List.Distinct(Table.TransformColumnTypes(#"Changed Type1", {{"Asset ID", type text}}, "en-AU")[#"Asset ID"]), "Asset ID", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"1", "Asset 1"}, {"2", "Asset 2"}, {"3", "Asset 3"}, {"4", "Asset 4"}})
in
    #"Renamed Columns"

 

IF no, please share an expected result

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

View solution in original post

1 REPLY 1
VahidDM
Super User
Super User

Hi @numersoz 

 

Is this an output you are looking for?

VahidDM_0-1642628664769.png

 

 

if yes, in Power Query select Asset and Value and use pivot column.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckksSVXSUXIsLk4tUfB0ATLDEnNKU5VidaKVDPUN9Y0MjIyAgoZAbGoAFTWCiYKwqSlU1BgmagzEZjC1JjBRE5AoUG0sAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Asset ID", Int64.Type}, {"Value", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type1", {{"Asset ID", type text}}, "en-AU"), List.Distinct(Table.TransformColumnTypes(#"Changed Type1", {{"Asset ID", type text}}, "en-AU")[#"Asset ID"]), "Asset ID", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"1", "Asset 1"}, {"2", "Asset 2"}, {"3", "Asset 3"}, {"4", "Asset 4"}})
in
    #"Renamed Columns"

 

IF no, please share an expected result

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

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.

Top Solution Authors