Forum Discussion
Handling Excel Matrixed Data
- 10 months ago
Is it your required format? workingdatapreplet Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type any}, {"Column4", type any}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}}), #"Transposed Table" = Table.Transpose(#"Changed Type"), #"Filled Down" = Table.FillDown(#"Transposed Table",{"Column1"}), #"Merged Columns" = Table.CombineColumns(#"Filled Down",{"Column1", "Column2"},Combiner.CombineTextByDelimiter("||", QuoteStyle.None),"Merged"), #"Transposed Table1" = Table.Transpose(#"Merged Columns"), #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table1", [PromoteAllScalars=true]), #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Type||", type text}, {"Category||", type text}, {"Jan 1 - Jan 30||Actual", Int64.Type}, {"Jan 1 - Jan 30||Planned", Int64.Type}, {"Feb 1 - Feb 28||Actual", Int64.Type}, {"Feb 1 - Feb 28||Planned", Int64.Type}, {"Mar 1 - Mar 30||Actual", Int64.Type}, {"Mar 1 - Mar 30||Planned", Int64.Type}}), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Type||", "Category||"}, "Attribute", "Value"), #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("||", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}), #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type2",{{"Type||", "Type"}, {"Category||", "Category"}, {"Attribute.1", "Date Range"}, {"Attribute.2", "Actual vs Planned"}, {"Value", "Sales Amount"}}) in #"Renamed Columns"
I’m assuming the dataset is quite simple. However, if you’re working with a larger dataset, you’ll need to handle the nested headers separately.
Hey workingdataprep ,
On the basis of what you have described, I have managed to do some transformations. Let me know if this is what you are looking for. If this isn't, do put the sample output of your file in order to get a better idea. I'll attach the image of the output and reference file of the output.
PS: The below file has the required new changes made.
Thanks,
- KarinSzilagyi10 months agoSuper User
Hi SundarRaj, just as a note: Your solution mixes the Planned and Actual Sales Values into one column without any way to distinguish them, which I personally wouldn't recommend
- SundarRaj10 months agoSuper User
Hi KarinSzilagyi, thanks for pointing that out!
Regards, - workingdataprep10 months agoNew Member
Yes, I'd like a column to differentiate actuals vs planned. Is there a way to do all of this?