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
DaubPitt
New Member

Transform Table from vertical to horizontal

Hello Community,

I read data from Excel files files that are stored in different folders. Every Excel file has the same structure. I performed some power query steps (as a beginner) to generate a table that's look good for my needs. But there is one thing, that I have to change. See screenshot.
How can I do this? I like to use the Excel data later for creating a Share Point List and the "Issue-No." will be the "Primary Key" = ID. 
Thank you in advance for any tips.

PQ Question.png

1 ACCEPTED SOLUTION

Hi @DaubPitt ,

 

Below are the setps.

1.Select two columns(Hold down the Ctrl key while the mouse selects.), then click 'Unpivot Columns'.

vstephenmsft_0-1653642341241.png

vstephenmsft_1-1653642405933.png

2.Remove the 'Attribute' column.

vstephenmsft_2-1653642440122.png

vstephenmsft_3-1653642447064.png

 

3.Change the 'Value' column to text type.

vstephenmsft_4-1653642493464.png

 

4.Group on ’Issue-No‘, choose some dummy operation for FULLNAME (e.g. Max, not "All Rows") and then adjust the generated code to combine the names.

vstephenmsft_5-1653643061941.png

 

5.Spilt the column with ";".

vstephenmsft_6-1653643090090.pngvstephenmsft_7-1653643108741.png

 

Result:

vstephenmsft_8-1653643399208.png

 

 

 

Best Regards,

Stephen 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

6 REPLIES 6
wdx223_Daniel
Super User
Super User

NewStep=Table.Combine(Table.Group(PreviousStepName,"Issue-No.",{"n",each #table(null,List.Combine(Table.ToRow(_)))})[n])

Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc5NDgARDAXgu1iLqCqZ5ZxD3P8a059BLSQv30M7RoCCIQbg80KYcUPKuSpqOEURLB74wqOo4RRdsHtIGXWQBSka1Xv6D/wVrunoCsUL+II+tyAFVgESJA9rT9p7WtEEm4cE9qeFOT8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Issue-No." = _t, #"Step-No" = _t, #"Step-No-Desc" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Issue-No."}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Issue-No."}, {{"Column", each Text.Combine([Value],";"), type any}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Column", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), List.Transform({1..List.Max(Table.AddColumn(#"Grouped Rows", "Temp", each List.Count(Text.Split([Column],";")))[Temp])},each "Column " & Number.ToText(_)))
in
    #"Split Column by Delimiter"

 

First of all, thank you very much for your quick support 🙂
I did the steps as you describe, but it does'nt work as I expected. See attached screenshot.
In this case, I only used the first row of source code. 
"Source = Table.FromRows(Json.Document(Binary.Decompress(..."
Why the Issue-No are different from Issue-No in my table?

PQ-01.jpg

Hi @DaubPitt ,

 

Below are the setps.

1.Select two columns(Hold down the Ctrl key while the mouse selects.), then click 'Unpivot Columns'.

vstephenmsft_0-1653642341241.png

vstephenmsft_1-1653642405933.png

2.Remove the 'Attribute' column.

vstephenmsft_2-1653642440122.png

vstephenmsft_3-1653642447064.png

 

3.Change the 'Value' column to text type.

vstephenmsft_4-1653642493464.png

 

4.Group on ’Issue-No‘, choose some dummy operation for FULLNAME (e.g. Max, not "All Rows") and then adjust the generated code to combine the names.

vstephenmsft_5-1653643061941.png

 

5.Spilt the column with ";".

vstephenmsft_6-1653643090090.pngvstephenmsft_7-1653643108741.png

 

Result:

vstephenmsft_8-1653643399208.png

 

 

 

Best Regards,

Stephen Tao

 

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

 

 

Wow, thank you !

Since your Excel doesn't contain any sensitive info, could you please upload the file without confidential/sensitive data to a cloud storage service such as Onedrive/Google Drive/Dropbox/Box (Onedrive preferred) and share the link here?

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