在Power Query中为字符串赋值

时间:2015-11-04 22:15:25

标签: excel if-statement powerbi powerquery

我有以下代码:

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

1 个答案:

答案 0 :(得分:1)

你想做这样的事情:

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

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