【发布时间】:2019-06-05 21:00:52
【问题描述】:
我有几列数据,我需要将excel版本的“PERCENTILE”转换成Powerquery格式。
我有一些代码作为函数添加,但不能准确应用,因为它不允许按类别和年份对数据进行分组。因此,Full Discretionary 1.5-2.5 AND 2014 中的任何内容都需要添加到百分位数数组中,同样,Full Discretionary 2.5-3.5 AND 2014 中的任何内容都需要添加到不同的百分位数数组中
let
Source = (list as any, k as number) => let
Source = list,
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Sorted Rows" = Table.Sort(#"Converted to Table",{{"Column1", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "TheIndex", each Table.RowCount(#"Converted to Table")*k/100),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each [Index] >= [TheIndex] and [Index] <= [TheIndex]+1),
Custom1 = List.Average(#"Filtered Rows"[Column1])
in
Custom1
in
Source
因此,预期结果将是在 2 列(Year,Category)上匹配的任何内容都应应用于同一数组中。目前调用上述函数只会给我错误。 我也尝试过使用分组并输出“最小值、中值和最大值”输出,但我还需要 10% 和 90% 的百分位数。
提前谢谢你
【问题讨论】:
标签: excel powerquery percentile