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.
Hi,
I have a spreadsheet (attached) that holds multi-level headers. I need to have the data transformed into a tabular format, so I can do some anaylsis.
May thanls
Solved! Go to Solution.
Below are the steps. Solution file uploaded to https://1drv.ms/x/s!Akd5y6ruJhvhuXVNE1rq8ooZx1rc?e=Mi2OhC
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Filtered Rows" = Table.SelectRows(Source, each not Text.Contains(Text.From([Column1]),"Total")),
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Region", each try if Text.Contains([Column1],"Region") then [Column1] else null otherwise null),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Department", each try if Text.Contains([Column1],"Department") then [Column1] else null otherwise null),
#"Filled Down" = Table.FillDown(#"Added Custom1",{"Region", "Department"}),
#"Removed Top Rows" = Table.Skip(#"Filled Down",2),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{"Region 1", "Region"}, {"Department 1", "Department"}}),
#"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Region", "Department", "#", "Name", "id", "date", "value", "Notes"}),
#"Filtered Rows1" = Table.SelectRows(#"Reordered Columns", each ([Name] <> null) and ([#"#"] <> "#")),
#"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows1",{{"Region", type text}, {"Department", type text}, {"#", Int64.Type}, {"Name", type text}, {"id", Int64.Type}, {"date", type datetime}, {"value", Int64.Type}, {"Notes", type text}})
in
#"Changed Type"
Below are the steps. Solution file uploaded to https://1drv.ms/x/s!Akd5y6ruJhvhuXVNE1rq8ooZx1rc?e=Mi2OhC
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Filtered Rows" = Table.SelectRows(Source, each not Text.Contains(Text.From([Column1]),"Total")),
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Region", each try if Text.Contains([Column1],"Region") then [Column1] else null otherwise null),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Department", each try if Text.Contains([Column1],"Department") then [Column1] else null otherwise null),
#"Filled Down" = Table.FillDown(#"Added Custom1",{"Region", "Department"}),
#"Removed Top Rows" = Table.Skip(#"Filled Down",2),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{"Region 1", "Region"}, {"Department 1", "Department"}}),
#"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Region", "Department", "#", "Name", "id", "date", "value", "Notes"}),
#"Filtered Rows1" = Table.SelectRows(#"Reordered Columns", each ([Name] <> null) and ([#"#"] <> "#")),
#"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows1",{{"Region", type text}, {"Department", type text}, {"#", Int64.Type}, {"Name", type text}, {"id", Int64.Type}, {"date", type datetime}, {"value", Int64.Type}, {"Notes", type text}})
in
#"Changed Type"
Thank you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.