Forum Discussion
RobRayborn
Helper IV
3 years agoPower Query, rollup Sat and Sun to Friday.
I have a report where orders that are taken on a Saturday and/or Sunday need to rollup or be combined with the orders from the previous Friday in each column that has order amounts. So if an order w...
- 3 years ago
Hi RobRayborn
This is my solution. Hope it is helpful.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc/BDcAgDAPAXfJGAocCYRbE/mtQVbJ59HsC21nLgIzsxd2S1Wo7feSkCFIlQa8e0qQ0Siuk/qchUlSQ+iBNFVJQVKhZ0Pqpn9B8qBPaP26eDugaAp1w43RCvLYP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Amount = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Amount", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "DayOfWeek", each Date.DayOfWeek([Date],Day.Monday)), #"Added Custom1" = Table.AddColumn(#"Added Custom", "WeekOfYear", each Date.WeekOfYear([Date],Day.Monday)), #"Replaced Value" = Table.ReplaceValue(#"Added Custom1",5,4,Replacer.ReplaceValue,{"DayOfWeek"}), #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",6,4,Replacer.ReplaceValue,{"DayOfWeek"}), #"Added Custom2" = Table.AddColumn(#"Replaced Value1", "WeekDayKey", each [WeekOfYear]*10+[DayOfWeek]), #"Grouped Rows" = Table.Group(#"Added Custom2", {"WeekDayKey"}, {{"New Date", each List.Min([Date]), type nullable date}, {"New Amount", each List.Sum([Amount]), type nullable number}}), #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"New Date", "New Amount"}) in #"Removed Other Columns"Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
v-jingzhang
Community Support
3 years agoHi RobRayborn
This is my solution. Hope it is helpful.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc/BDcAgDAPAXfJGAocCYRbE/mtQVbJ59HsC21nLgIzsxd2S1Wo7feSkCFIlQa8e0qQ0Siuk/qchUlSQ+iBNFVJQVKhZ0Pqpn9B8qBPaP26eDugaAp1w43RCvLYP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Amount = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Amount", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "DayOfWeek", each Date.DayOfWeek([Date],Day.Monday)),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "WeekOfYear", each Date.WeekOfYear([Date],Day.Monday)),
#"Replaced Value" = Table.ReplaceValue(#"Added Custom1",5,4,Replacer.ReplaceValue,{"DayOfWeek"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",6,4,Replacer.ReplaceValue,{"DayOfWeek"}),
#"Added Custom2" = Table.AddColumn(#"Replaced Value1", "WeekDayKey", each [WeekOfYear]*10+[DayOfWeek]),
#"Grouped Rows" = Table.Group(#"Added Custom2", {"WeekDayKey"}, {{"New Date", each List.Min([Date]), type nullable date}, {"New Amount", each List.Sum([Amount]), type nullable number}}),
#"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"New Date", "New Amount"})
in
#"Removed Other Columns"
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.