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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Imagauthamam
Helper III
Helper III

Transformation Help Required in Power Query

I have a data in a certain format and it needs to be converted properly in Power query editor.
I tried using unpivot, Transpose and pivot operations.
But somehow im not able to transform it properly.

INPUT:

Imagauthamam_0-1728126781516.png

 


EXPECTED OUTPUT:

Imagauthamam_1-1728126836569.png


It will be great if somebody can solve this and explain step by step.
Thanks in advance!

 

2 ACCEPTED SOLUTIONS
rajendraongole1
Super User
Super User

Hi @Imagauthamam - In  Power Query Editor and achieve the expected output as like below:

 

rajendraongole1_0-1728129030242.png

 

Mcode:

let
// Load the source data
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nRRitWJVvJLzE0FM3zykxNLMvPzwBxDMBmcmAuVykuBShhBJErzUhKLIPpTyxUi84uywRxjMOmYAtXnkpqTkakUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),

// Change column type
ChangedType = Table.TransformColumnTypes(Source, {{"Column1", type text}}),

// Add Index Column
AddIndex = Table.AddIndexColumn(ChangedType, "Index", 0, 1, Int64.Type),

// Create a Custom Column for Type
AddedCustom = Table.AddColumn(AddIndex, "Type", each if Number.Mod([Index], 3) = 0 then "ID" else if Number.Mod([Index], 3) = 1 then "Name" else "Location"),
#"Pivoted Column" = Table.Pivot(AddedCustom, List.Distinct(AddedCustom[Type]), "Type", "Column1"),
#"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index"}),
#"Removed Top Rows" = Table.Skip(#"Removed Columns",1),
#"Filled Down" = Table.FillDown(#"Removed Top Rows",{"ID", "Name", "Location"}),
#"Removed Duplicates" = Table.Distinct(#"Filled Down"),
#"Removed Duplicates1" = Table.Distinct(#"Removed Duplicates", {"Name"}),
#"Removed Top Rows1" = Table.Skip(#"Removed Duplicates1",1)
in
#"Removed Top Rows1"

 

Hope this helps

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Can be done in a single step

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    Custom1 = Table.FromRows(List.Split(Table.Skip(Source,3)[Column1],3),Table.FirstN(Source,3)[Column1])
in
    Custom1

Hope this helps.

Ashish_Mathur_0-1728184309155.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Can be done in a single step

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    Custom1 = Table.FromRows(List.Split(Table.Skip(Source,3)[Column1],3),Table.FirstN(Source,3)[Column1])
in
    Custom1

Hope this helps.

Ashish_Mathur_0-1728184309155.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Imagauthamam
Helper III
Helper III

Thank you so much @rajendraongole1 .
This works like a gem

rajendraongole1
Super User
Super User

Hi @Imagauthamam - In  Power Query Editor and achieve the expected output as like below:

 

rajendraongole1_0-1728129030242.png

 

Mcode:

let
// Load the source data
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nRRitWJVvJLzE0FM3zykxNLMvPzwBxDMBmcmAuVykuBShhBJErzUhKLIPpTyxUi84uywRxjMOmYAtXnkpqTkakUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),

// Change column type
ChangedType = Table.TransformColumnTypes(Source, {{"Column1", type text}}),

// Add Index Column
AddIndex = Table.AddIndexColumn(ChangedType, "Index", 0, 1, Int64.Type),

// Create a Custom Column for Type
AddedCustom = Table.AddColumn(AddIndex, "Type", each if Number.Mod([Index], 3) = 0 then "ID" else if Number.Mod([Index], 3) = 1 then "Name" else "Location"),
#"Pivoted Column" = Table.Pivot(AddedCustom, List.Distinct(AddedCustom[Type]), "Type", "Column1"),
#"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index"}),
#"Removed Top Rows" = Table.Skip(#"Removed Columns",1),
#"Filled Down" = Table.FillDown(#"Removed Top Rows",{"ID", "Name", "Location"}),
#"Removed Duplicates" = Table.Distinct(#"Filled Down"),
#"Removed Duplicates1" = Table.Distinct(#"Removed Duplicates", {"Name"}),
#"Removed Top Rows1" = Table.Skip(#"Removed Duplicates1",1)
in
#"Removed Top Rows1"

 

Hope this helps

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.