如何从 Power M 代码中的嵌套 table 获取值
How can I get a value from a nested table in Power M Code
我想获取 [GroupIndex] 的 Max
值,然后用它来划分 [Monthly Target] 以创建 [Target]。
问题是我不知道如何从嵌套的 table.
中获取单个值
这是我目前尝试过的方法:
像这样使用Table.RowCount()
:
=Table.TransformColumns(Test, {"Count", each Table.AddColumn(_, "Target", each [Monthly Target]/Table.RowCount(_))})
Error: We cannot apply operator / to types Number and Function.
我做了一个嵌套列表,然后要求操作的最大值:
=Table.TransformColumns(Test, {"Count", each [GroupIndex]})
=Table.TransformColumns(Test, {"Count", each Table.AddColumn(_, "Target", each [Monthly Target]/List.Max(Test2))})
Error: We cannot convert a value of type Table to type List.
我尝试使用 List.Max()
获取值,然后在最后一行使用它们进行除法:
=Table.TransformColumns(Test, {"Count", each List.Max([GroupIndex])})
=Table.TransformColumns(Test, {"Count", each Table.AddColumn(_, "Target", each [Monthly Target]/Test2)})
Error : We cannot apply operator / to types Number and Table.
我想在 Expand
所有 table 之前得到这个部门。
感谢任何帮助。谢谢!
我会为您的 Count Table 类型的列点击 Expand 按钮,然后选择 Aggregate 选项,然后 select 只有列 GroupIndex 和 Monthly Target。
UI 将生成 List.Count 或 List.Sum 函数调用(取决于数据类型)- 然后您可以将公式栏中的那些编辑为 List.Max。这应该适用于您的特定场景,但可以根据需要应用其他 List 函数。
供将来参考 来自另一个论坛的 Imke Feldmann 给了我这个答案并且它完美地工作了。
嗨大卫,
您不能在一条命令中两次使用 "each"-关键字。而是使用这样的标准函数语法:
=Table.TransformColumns(Test, {"Count", each Table.AddColumn(_, "Target", (inner) => inner[Monthly Target]/Table.RowCount(_))})
我想获取 [GroupIndex] 的 Max
值,然后用它来划分 [Monthly Target] 以创建 [Target]。
问题是我不知道如何从嵌套的 table.
中获取单个值这是我目前尝试过的方法:
像这样使用
Table.RowCount()
:=Table.TransformColumns(Test, {"Count", each Table.AddColumn(_, "Target", each [Monthly Target]/Table.RowCount(_))})
Error: We cannot apply operator / to types Number and Function.
我做了一个嵌套列表,然后要求操作的最大值:
=Table.TransformColumns(Test, {"Count", each [GroupIndex]}) =Table.TransformColumns(Test, {"Count", each Table.AddColumn(_, "Target", each [Monthly Target]/List.Max(Test2))})
Error: We cannot convert a value of type Table to type List.
我尝试使用
List.Max()
获取值,然后在最后一行使用它们进行除法:=Table.TransformColumns(Test, {"Count", each List.Max([GroupIndex])}) =Table.TransformColumns(Test, {"Count", each Table.AddColumn(_, "Target", each [Monthly Target]/Test2)})
Error : We cannot apply operator / to types Number and Table.
我想在 Expand
所有 table 之前得到这个部门。
感谢任何帮助。谢谢!
我会为您的 Count Table 类型的列点击 Expand 按钮,然后选择 Aggregate 选项,然后 select 只有列 GroupIndex 和 Monthly Target。
UI 将生成 List.Count 或 List.Sum 函数调用(取决于数据类型)- 然后您可以将公式栏中的那些编辑为 List.Max。这应该适用于您的特定场景,但可以根据需要应用其他 List 函数。
供将来参考 来自另一个论坛的 Imke Feldmann 给了我这个答案并且它完美地工作了。
嗨大卫,
您不能在一条命令中两次使用 "each"-关键字。而是使用这样的标准函数语法:
=Table.TransformColumns(Test, {"Count", each Table.AddColumn(_, "Target", (inner) => inner[Monthly Target]/Table.RowCount(_))})