Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Need help in transforming the table.

Hello,

 

I am in the learning phase of the Power BI. I have been struggling on one problem for last three days. I have this below table.

 

naveen_772_0-1623098676281.png

 I need to transform this into table looking like below.

naveen_772_1-1623098734506.png

 

Any help would be really appreciated.

 

Please just drop any tips if you don't think of any proper solution. 

 

Thank You

 

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 
Paste this code in a New Blank Query in the Advanced Editor and check the steps. All using GUI.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Pcw7C4QwEATgv7JsbWOCsfbR2MhxbUgRNHAH9wARMfvrdQJJkWHYj4y1/PBb+O30DMt/W2kaKXLFw+v9WfNt9t9w30a/B6pzUbloOthVliHd/U6UiJC6QA/Al4gQVWAAaABCdAKVpxoAQpoCacoAEMoUSFMtACEtO3cB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Merged Columns" = Table.CombineColumns(#"Promoted Headers",{"Date 1", "Date 2", "Date 3 v"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[#"Child Record Name"]), "Child Record Name", "Merged"),
    #"Merged Columns1" = Table.CombineColumns(#"Pivoted Column",{"A", "B", "C"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Merged Columns1", "Merged", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Merged.1", "Merged.2", "Merged.3", "Merged.4", "Merged.5", "Merged.6", "Merged.7", "Merged.8", "Merged.9"})
in
    #"Split Column by Delimiter"

Fowmy_0-1623099291808.png

 

 



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

4 REPLIES 4
Fowmy
Super User
Super User

@Anonymous 
Paste this code in a New Blank Query in the Advanced Editor and check the steps. All using GUI.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Pcw7C4QwEATgv7JsbWOCsfbR2MhxbUgRNHAH9wARMfvrdQJJkWHYj4y1/PBb+O30DMt/W2kaKXLFw+v9WfNt9t9w30a/B6pzUbloOthVliHd/U6UiJC6QA/Al4gQVWAAaABCdAKVpxoAQpoCacoAEMoUSFMtACEtO3cB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Merged Columns" = Table.CombineColumns(#"Promoted Headers",{"Date 1", "Date 2", "Date 3 v"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[#"Child Record Name"]), "Child Record Name", "Merged"),
    #"Merged Columns1" = Table.CombineColumns(#"Pivoted Column",{"A", "B", "C"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Merged Columns1", "Merged", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Merged.1", "Merged.2", "Merged.3", "Merged.4", "Merged.5", "Merged.6", "Merged.7", "Merged.8", "Merged.9"})
in
    #"Split Column by Delimiter"

Fowmy_0-1623099291808.png

 

 



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

Anonymous
Not applicable

You made my day. Thank you so much.

 

Is there any way where we can retain the column name?

@Anonymous 

Please find below the code with the Column Names renamed as desired:

 

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "PYw7CoAwEESvEra2SUSt/TQ2IrYhRTABBT8gFrqn11GSYh/DPHa0pt4efjvF4Mf9cKJtKKF6mhcXms6u/u0ae3ohQ1AhpGQSTejL9y6EG2AZRQWBhxtgFUUNkUIA/E+pMJVBAJxF8U3lEIDKo/imCgiACzLmAQ==",
          BinaryEncoding.Base64
        ),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [
        #"(blank)" = _t,
        #"(blank).1" = _t,
        #"(blank).2" = _t,
        #"(blank).3" = _t,
        #"(blank).4" = _t
      ]
  ),
  #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars = true]),
  #"Merged Columns" = Table.CombineColumns(
    #"Promoted Headers",
    {"Date 1", "Date 2", "Date 3"},
    Combiner.CombineTextByDelimiter("|", QuoteStyle.None),
    "Merged"
  ),
  #"Pivoted Column" = Table.Pivot(
    #"Merged Columns",
    List.Distinct(#"Merged Columns"[#"Child Record Name"]),
    "Child Record Name",
    "Merged"
  ),
  #"Merged Columns1" = Table.CombineColumns(
    #"Pivoted Column",
    {"A", "B", "C"},
    Combiner.CombineTextByDelimiter("|", QuoteStyle.None),
    "Merged"
  ),
  Step1 = Table.SplitColumn(
    #"Merged Columns1",
    "Merged",
    Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv),
    {
      "Merged.1",
      "Merged.2",
      "Merged.3",
      "Merged.4",
      "Merged.5",
      "Merged.6",
      "Merged.7",
      "Merged.8",
      "Merged.9"
    }
  ),
  Custom2 = Table.ExpandListColumn(
    Table.AddColumn(
      Table.FromList(
        List.Distinct(#"Promoted Headers"[Child Record Name]),
        Splitter.SplitByNothing(),
        null,
        null,
        ExtraValues.Error
      ),
      "Custom",
      each List.Skip(Table.ColumnNames(#"Promoted Headers"), 2)
    ),
    "Custom"
  ),
  NewHeaderList = Table.AddColumn(Custom2, "NewHeader", each [Column1] & " (" & [Custom] & ")")[
    NewHeader
  ],
  OldHeaderList = List.Skip(Table.ColumnNames(Step1), 1),
  Step3 = Table.ToColumns(
    Table.Transpose(Table.FromColumns({OldHeaderList, NewHeaderList}, {"Old", "New"}))
  ),
  #"Renamed Columns" = Table.RenameColumns(Step1, Step3)
in
  #"Renamed Columns"

 

Fowmy_0-1623144399651.png

 

 

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

@Anonymous 

 

I will see that when I have time for sure. 

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.