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

Unpivot Option

Hi,

 

Iam having a challenge to transition data structure, I need the grey column (type of transactions: sales, debit, credit, etc.) become in columns, ao I am able to subtract some of those columns based on the attirbutes. How do I transition transaction type to columns:

 

For example:

Custome  Product   Date   Transfer   Debit  Sales

 

this is what I currently have Capture.JPG

 

 

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I created a sample pbix file(see attachment), please check whether that is what you want. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rZNNC4IwGMe/iuys6DPf1jG06BAo6U08LFsUVBOdh759O4RSytjA097gx7P/73mqCm2P6e60z7K0QDYq6IP1cs350NxYbzkH2rZvq+RCXia8Y9b3RR7BBRd7GOTWISGq7T9W2dFXf2WdNg6POEzmuJSd70Kb5U+sYM5Khl7wpzYsGGGRP4flHb8MjX5p4URbKC2lgmmjohHlL6DMZMbKxIxlEmVmZjI3a8oEb1WbAOvpBLyiT1CPgLFQCJTTbmYUQuWsmyqNlF81zC1W9od5buSnQeoP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer Group" = _t, Transaction = _t, #"LV2 PL" = _t, #"Product Group" = _t, Dates = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Group", type text}, {"Transaction", type text}, {"LV2 PL", type text}, {"Product Group", type text}, {"Dates", type date}, {"Value", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Customer Group", "LV2 PL", "Product Group", "Dates", "Value"}, "Attribute", "Transaction Type"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Unpivoted Columns"[#"Transaction Type"]), "Transaction Type", "Attribute")
in
    #"Pivoted Column"

yingyinr_0-1625216302297.png

If the above one is not working for you, please provide more details on your requirement. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I created a sample pbix file(see attachment), please check whether that is what you want. 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rZNNC4IwGMe/iuys6DPf1jG06BAo6U08LFsUVBOdh759O4RSytjA097gx7P/73mqCm2P6e60z7K0QDYq6IP1cs350NxYbzkH2rZvq+RCXia8Y9b3RR7BBRd7GOTWISGq7T9W2dFXf2WdNg6POEzmuJSd70Kb5U+sYM5Khl7wpzYsGGGRP4flHb8MjX5p4URbKC2lgmmjohHlL6DMZMbKxIxlEmVmZjI3a8oEb1WbAOvpBLyiT1CPgLFQCJTTbmYUQuWsmyqNlF81zC1W9od5buSnQeoP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer Group" = _t, Transaction = _t, #"LV2 PL" = _t, #"Product Group" = _t, Dates = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Group", type text}, {"Transaction", type text}, {"LV2 PL", type text}, {"Product Group", type text}, {"Dates", type date}, {"Value", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Customer Group", "LV2 PL", "Product Group", "Dates", "Value"}, "Attribute", "Transaction Type"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Unpivoted Columns"[#"Transaction Type"]), "Transaction Type", "Attribute")
in
    #"Pivoted Column"

yingyinr_0-1625216302297.png

If the above one is not working for you, please provide more details on your requirement. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HotChilli
Super User
Super User

Pivot?

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.