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
Syndicate_Admin
Administrator
Administrator

structure table

Good morning, I need to convert a table into a power query editor as follows:

Initial table:

nullnullmes1mes1mes2mes2mes3mes3
null nullfirst fortnightsecond fortnightfirst fortnightsecond fortnightfirst fortnightsecond fortnight
person 1tipo1123456
persona1tipo25843825
person 2tipo1123456
persona2tipo25843825
person 3tipo1123456
persona3tipo25843825

Table to get:

personguymyfortnightvalue
persona1tipo1mes1first fortnight1
persona1tipo1mes1 second fortnight2
persona1tipo1mes2first fortnight3
persona1tipo1mes2second fortnight4
persona1tipo1mes3first fortnight5
persona1tipo1mes3second fortnight6
persona1tipo2mes1first fortnight5
persona1tipo2mes1 second fortnight8
persona1tipo2mes2first fortnight4
persona1tipo2mes2second fortnight3
persona1tipo2mes3first fortnight8
persona1tipo2mes3second fortnight25
persona2tipo1mes1 first fortnight1
persona2tipo1mes1 second fortnight2
persona2tipo1mes2first fortnight3
persona2tipo1mes2second fortnight4
persona2tipo1mes3first fortnight5
persona2tipo1mes3second fortnight6
persona2tipo2mes1first fortnight5
persona2tipo2mes1 second fortnight8
persona2tipo2mes2first fortnight4
persona2tipo2mes2second fortnight3
persona2tipo2mes3first fortnight8
persona2tipo2mes3second fortnight25
persona3tipo1mes1 first fortnight1
persona3tipo1mes1 second fortnight2
persona3tipo1mes2first fortnight3
persona3tipo1mes2second fortnight4
persona3tipo1mes3first fortnight5
persona3tipo1mes3second fortnight6
persona3tipo2mes1first fortnight5
persona3tipo2mes1 second fortnight8
persona3tipo2mes2first fortnight4
persona3tipo2mes2second fortnight3
persona3tipo2mes3first fortnight8
persona3tipo2mes3second fortnight25

I hope I have explained myself.

Thank you very much in advance

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Syndicate_Admin 
Create a blank Query, go to the Advanced Editor, clear the existing code, and paste the codes give below and follow the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WyivNyVHSgVG5qcWGKJQRCmUMo2J10HWmZRYVlyik5ReV5GWmZ5QARYpTk/PzUlCEqKUIZH1BalFxfp4CyJ0lmQX5IBqEQS4FOdMEiE2B2AxJcSJMsRFU0gKq0BjKNjJFNtqIFKONSDLamBSjjYkwOhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t, Column8 = _t]),
    #"Transposed Table" = Table.Transpose(Source),
    #"Merged Columns" = Table.CombineColumns(#"Transposed Table",{"Column1", "Column2"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Transposed Table1" = Table.Transpose(#"Merged Columns"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table1", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"null|null", type text}, {"null|null_1", type text}, {"mes1|first fortnight", Int64.Type}, {"mes1|second fortnight", Int64.Type}, {"mes2|first fortnight", Int64.Type}, {"mes2|second fortnight", Int64.Type}, {"mes3|first fortnight", Int64.Type}, {"mes3|second fortnight", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"null|null", "null|null_1"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"null|null", "Person"}, {"null|null_1", "Guy"}, {"Attribute.1", "My"}, {"Attribute.2", "Fortnight"}})
in
    #"Renamed Columns"

Fowmy_0-1623422391564.png


Watch my video on this topic : https://www.youtube.com/watch?v=_YjFGsS9lNY&t=0s

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Thank you so much

Fowmy
Super User
Super User

@Syndicate_Admin 
Create a blank Query, go to the Advanced Editor, clear the existing code, and paste the codes give below and follow the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WyivNyVHSgVG5qcWGKJQRCmUMo2J10HWmZRYVlyik5ReV5GWmZ5QARYpTk/PzUlCEqKUIZH1BalFxfp4CyJ0lmQX5IBqEQS4FOdMEiE2B2AxJcSJMsRFU0gKq0BjKNjJFNtqIFKONSDLamBSjjYkwOhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t, Column8 = _t]),
    #"Transposed Table" = Table.Transpose(Source),
    #"Merged Columns" = Table.CombineColumns(#"Transposed Table",{"Column1", "Column2"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Transposed Table1" = Table.Transpose(#"Merged Columns"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table1", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"null|null", type text}, {"null|null_1", type text}, {"mes1|first fortnight", Int64.Type}, {"mes1|second fortnight", Int64.Type}, {"mes2|first fortnight", Int64.Type}, {"mes2|second fortnight", Int64.Type}, {"mes3|first fortnight", Int64.Type}, {"mes3|second fortnight", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"null|null", "null|null_1"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"null|null", "Person"}, {"null|null_1", "Guy"}, {"Attribute.1", "My"}, {"Attribute.2", "Fortnight"}})
in
    #"Renamed Columns"

Fowmy_0-1623422391564.png


Watch my video on this topic : https://www.youtube.com/watch?v=_YjFGsS9lNY&t=0s

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.