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
Chloestevens88
Regular Visitor

Convert rows into columns

Hi All, wondering if anyone can help??

I have this set of date in this format 

Chloestevens88_0-1710857054366.png

and what i want it to look like is this

Chloestevens88_1-1710857160674.png

Almost like an unpivot with the Step being the header, but not with values.

 

Any ideas anyone?

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

Hi @Chloestevens88 ,

Here is my sample data:

vjunyantmsft_0-1710904680806.png

 


Please try this M function, just put all of the M function into the Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnFV0lEy1DfUNzIwMgYyg0tSCxQMgYziksSiEqVYHfKVGAEZ+UUpqUVgJe5OOExJzkgswa0CZEhBUX5KaTLRNmFVAmKk5qUQbxFWRVBTFOBuJmgXWIEx3sAD24RTCZpd+I3CqgRLPJBrG5aAJsM2rEGNrgh7UGNTlZiemgdUEgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Market = _t, Date = _t, Step = _t, Context = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Market", type text}, {"Date", type date}, {"Step", type text}, {"Context", type text}}),
    #"Removed Duplicates" = Table.Distinct(#"Changed Type"),
    #"Pivoted Column" = Table.Pivot(#"Removed Duplicates", List.Distinct(#"Removed Duplicates"[Step]), "Step", "Context")
in
    #"Pivoted Column"

 And the final output is as below:

vjunyantmsft_1-1710904700392.png


Best Regards,
Dino Tao
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

4 REPLIES 4
v-junyant-msft
Community Support
Community Support

Hi @Chloestevens88 ,

Here is my sample data:

vjunyantmsft_0-1710904680806.png

 


Please try this M function, just put all of the M function into the Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnFV0lEy1DfUNzIwMgYyg0tSCxQMgYziksSiEqVYHfKVGAEZ+UUpqUVgJe5OOExJzkgswa0CZEhBUX5KaTLRNmFVAmKk5qUQbxFWRVBTFOBuJmgXWIEx3sAD24RTCZpd+I3CqgRLPJBrG5aAJsM2rEGNrgh7UGNTlZiemgdUEgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Market = _t, Date = _t, Step = _t, Context = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Market", type text}, {"Date", type date}, {"Step", type text}, {"Context", type text}}),
    #"Removed Duplicates" = Table.Distinct(#"Changed Type"),
    #"Pivoted Column" = Table.Pivot(#"Removed Duplicates", List.Distinct(#"Removed Duplicates"[Step]), "Step", "Context")
in
    #"Pivoted Column"

 And the final output is as below:

vjunyantmsft_1-1710904700392.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

dufoq3
Super User
Super User

If you want us to help you, provide sample data in proper format.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

dufoq3
Super User
Super User

Hi @Chloestevens88,

 

  • for future requests, provide sample data as table so we can copy/paste
  • this video should help you

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Thanks but this doesnt work with the additional columns for country and date 

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
Top Kudoed Authors