I'm looking to write a DataTransform for an imported csv file which performs the following:
- GroupBy: State
- Action: Sums all columns
The output I'm looking for would show a row each State, a column for each date, and the sum for that date. Just using the Table.Group and List.Sum, I'm able to get this for specific dates:
= Table.Group(#"Change Dates to Num", {"Province_State"}, {{"4/19/20", each List.Sum([#"4/19/20"]), type number}, {"4/20/20", each List.Sum([#"4/20/20"]), type number}})
I don't know how many dates are in the input though so I'm looking for this to do this for N columns:
= Table.Group(#"Change Dates to Num", {"Province_State"}, List.Transform(List.RemoveFirstN(Table.ColumnNames(#"Promoted Headers"),4), (DateList) => {DateList,each List.Sum(Table.Column(#"Change Dates to Num",DateList)), type number}))
The above gives me the correct number of columns and rows but the List.Sum is not right.
Thanks for the help.