@choicechoi
不难写那就自己写吧,pq参考。
let
源 = Excel.CurrentWorkbook(){[Name="data"]}[Content],
类型 = Table.TransformColumnTypes(源,{{"polno", type text}, {"clntcode", type text}, {"certno", type text}, {"dob", type datetime}, {"sex", type text}}),
周岁 = Table.Buffer(Table.AddColumn(类型, "age",each Number.Round( Duration.Days( DateTime.LocalNow()-[dob])/365.25,1),type number )),
结果 = Table.Group(周岁, {"polno"}
, {
{"女性总人数", each Table.RowCount(Table.SelectRows(_, each [sex] = "F")), Int64.Type}
,{"平均年龄", each Number.Round(List.Average(Table.SelectRows(_, each [sex] = "F")[age]),1), type number}
,{"[20,30)女性总人数", each Table.RowCount(Table.SelectRows(_, each [sex] = "F" and [age]>=20 and [age]<30)), Int64.Type}
,{"[30,40)女性总人数", each Table.RowCount(Table.SelectRows(_, each [sex] = "F" and [age]>=30 and [age]<40)), Int64.Type}
}
)
in
结果