The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Can someone pls advise if its possible to merge data from cells in 2 rows. In the below screenshot, I want the data from columns B-E against the name and add the date in a separate column. In the source excel, the data is against the date.
Expected outcome:
Thanks and appreciate your support.
Good Day gauravg3,
There will be more elegant ways to do this but here's an approach which works...
The result looks as follows
The code looks as follows
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Start Date", type any}, {"Duration A", type number}, {"Duration B", type number}, {"Duraction C", type number}, {"Duration D", type number}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Name", each if Number.IsOdd([Index]) then #"Changed Type"[Start Date]{[Index]-1} else null),
#"Removed Alternate Rows" = Table.AlternateRows(#"Added Custom",0,1,1),
#"Removed Other Columns" = Table.SelectColumns(#"Removed Alternate Rows",{"Start Date", "Duration A", "Duration B", "Duraction C", "Duration D", "Name"}),
#"Extracted Date" = Table.TransformColumns(#"Removed Other Columns",{{"Start Date", DateTime.Date, type date}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Extracted Date",{{"Name", type text}}),
#"Reordered Columns" = Table.ReorderColumns(#"Changed Type1",{"Name", "Duration A", "Duration B", "Duraction C", "Duration D", "Start Date"})
in
#"Reordered Columns"
I've attached an example Excel file.
Hope this helps
Hey @gauravg3,
Looking at your screenshots, you want to transform data from having dates as row headers to having names as row headers with dates in a separate column.
Solution Steps:
Alternative approach if above doesn't work:
Try the unpivot method first, it should give you the exact structure shown in your second image.
Fixed? ✓ Mark it • Share it • Help others!
Best Regards,
Jainesh Poojara | Power BI Developer