let
源 = Excel.CurrentWorkbook(){[Name="表1_2"]}[Content],
自定义1 = Table.AddColumn(源,"日期",each [时间]),
自定义2 = Table.TransformColumns(自定义1,{{"时间",each if DateTime.Time(_)<#time(9,0,0) then "次日"&Time.ToText(DateTime.Time(_)) else DateTime.Time(_)},{"日期",each if DateTime.Time(_)<#time(9,0,0) then Date.ToText(Date.AddDays(DateTime.Date(_),-1)) else Date.ToText(DateTime.Date(_))}}),
自定义3 = Table.Pivot(自定义2,List.Distinct(自定义2[日期]),"日期","值"),
#"9-23" = List.Transform(List.Skip(Table.ToColumns(Table.SelectRows(自定义3,each try Time.Hour([时间])>8 otherwise false))),List.Sum),
#"0-8" = List.Transform(List.Skip(Table.ToColumns(Table.SelectRows(自定义3,each try Time.Hour([时间])<8 otherwise true))),List.Sum),
合计 = List.Transform(List.Skip(Table.ToColumns(自定义3)),List.Sum),
自定义4 = 自定义3 & Table.FromRows(List.Transform(List.Zip({{{"9-23"},{"0-8"},{"合计"}},{#"9-23",#"0-8",合计}}),List.Combine),Table.ColumnNames(自定义3))
in
自定义4 |