【问题标题】:Power Query -- list value in native queryPower Query -- 在本机查询中列出值
【发布时间】:2015-11-25 20:01:50
【问题描述】:

我在本机查询中使用“in”运算符时遇到问题,其中 in 参数是通过钻取 excel 列表检索到的列表:

let
   var = Number.ToText(fnFuncao("externalcode")),
   Coluna= Excel.CurrentWorkbook(){[Name="Pendente"]}[Content],
   #"Changed Type" = Table.TransformColumnTypes(Coluna,{{"PARAMETER", Int64.Type}, {"INTERACTION_ID", Int64.Type}, {"INTERACTION_ITEM", Int64.Type}}),
   INTERACTION_ID = #"Changed Type"[INTERACTION_ID][0],
   Source = Oracle.Database("somp", [Query="select * from ish.ticket where    interaction_id in (" & INTERACTION_ID & ") "])
in
    Source

Error:
    Expression.Error: We cannot apply operator & to types Text and List.
    Details:
    Operator=&
    Left=select * from ish.ticket where interaction_id in (
    Right=List

有什么办法可以解决这个问题? 谢谢!

【问题讨论】:

    标签: expression powerquery nativequery


    【解决方案1】:

    我不知道为什么 INTERACTION_ID 被视为一个列表。这两项更改应该可以解决您的问题:

    1. 将 INTERACTION_ID 更改为 #"Changed Type"[INTERACTION_ID]{0},
    2. 将查询设置为"select * from ish.ticket where interaction_id in (" & Number.ToText(INTERACTION_ID) & ")"

    第一个更改使用列表访问运算符 {} 而不是记录访问运算符 []。第二个更改将 INTERACTION_ID 转换为 Text 值,以便可以使用 & 将其添加到其他 Text 值。

    【讨论】:

    • 如果我的interaction_id 列在单元格a1、b1、c1 中有值怎么办。有没有办法在查询中包含所有值?
    • 删除 INTERACTION_ID 步骤并将其用于查询:"select * from ish.ticket where interaction_id in (" & List.Accumulate(List.Skip(#"Changed Type"[INTERACTION_ID], 1), Number.ToText(#"Changed Type"[INTERACTION_ID]{0}), (state, current) => state & ", " & Number.ToText(current)) & ")" 这将遍历列并在第一个元素后附加逗号。这仅在您的列中有值时才有效。
    猜你喜欢
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-22
    • 2019-03-28
    相关资源
    最近更新 更多