逻辑弄错了,以为是在>n, 小于n+1的范围就是n,更改下逻辑就OK了
- = Table.CombineColumns(
- Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
- {"均值","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"},
- (Result)=>let
- a = Result{0}, b = List.Range(Result,1),
- c = List.Sum(
- List.Transform(
- {0..15},each if b{_} is null then null
- else
- if (a>=b{_} and b{_+1} is null ) then _
- else
- if (a>=b{_} and a< b{_+1} ) then if Number.Abs(b{_}-a)>Number.Abs(b{_+1}-a) then _+1 else _
- else null ) )
- in "L"&Text.PadStart(Text.From(c),2,"0") , "Result")
复制代码 |