Forum Discussion
jgclarke
8 years agoNew Member
Flattening Rows Containing Values and Text Dynamically
I have unpivotted / pivotted my data and created a table that grows dynamically (ie: Each new month added will result in a new "value" column and a new "Notes" column. The table is shown below: ...
- 8 years ago
HI jgclarke,
Based on the information given I think that your raw data looks like this:
If that is the case then the following will get the data in the shape that you want (Change the Source step to refer to your table)
let Source = Table #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}, {"Customer", type text}, {"Value", type number}, {"Comment", type text}}), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Month", "Customer"}, "Attribute", "Value.1"), #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Custom", each [Attribute]& "-" & [Month]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Attribute", "Month"}), #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Custom]), "Custom", "Value.1") in #"Pivoted Column" - 8 years ago
Thank you MarkS
That works 100%.
I think that I was overcomplicating my code.
deevaker
8 years agoResolver I
Hi jgclarke,
If the number of columns are not much, you can apply max function on the columns
like : Value Jan 18 New = max(Value Jan 18)
So, that when you pull it against Account it will show only max values but not null
Thanks