在 Power Query 中为字符串赋值

Assigning value to a string in Power Query

我有以下代码:

let
    Condition = Excel.CurrentWorkbook(){[Name="test_table"]}[Content],
    field = Condition{0}[field_excel],  
    str = "One",
    query = if field <> null
        then str = "two" 
        else str = "three",
    exec= Oracle.Database("TESTING", [Query=str])
in
    exec

我想根据条件 str 获得 twothree 的值,但始终保持 One

您想做这样的事情:

...
field = Condition{0}[field_excel],
str   = if field <> null then "two" else "three",
exec  = Oracle.Database("TESTING", [Query = str]),
...

Power Query 不允许您将值重新分配给 let 表达式中的变量。相反,您会将值分配给新变量。