Forum Discussion
Anonymous
2 years agoNot applicable
transforming excel sheet in power query editor
I am new to power query editor. I have an excel sheet with three columns, Notification, Stat., and Date. Each column has 1311 rows. I want the notification column to stay where it is. I need all 1311...
ronrsnfld
2 years agoSuper User
I am assuming that you must have multiple rows with the same notification but different Stat and Date, and that your example is not realistic.
Perhaps a more realistic data source would look like:
That being the case, the below might be what you want:
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Notification", Int64.Type}, {"Stat.", type text}, {"Date", type date}}),
//will be used below in Pivot
Stats = List.Sort(List.Distinct(#"Changed Type"[#"Stat."])),
fieldTypes = List.Repeat({type nullable date}, List.Count(Stats)),
rowColumnTypes = List.Transform(fieldTypes, (t) => [Type = t, Optional = false]),
rowType = Type.ForRecord(Record.FromList(rowColumnTypes, Stats),false),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Notification"}, {
{"Pivot", each Table.Pivot(_, Stats,"Stat.","Date"), type table rowType}}),
#"Expanded Pivot" = Table.ExpandTableColumn(#"Grouped Rows", "Pivot", Stats)
in
#"Expanded Pivot"
producing:
- Anonymous2 years agoNot applicable
You're a life saver! I am going to try this! I will have to find where I can enter M-code in power query editor! Thank you so much! I will update if this works!