2017年12月13日 星期三

Published 下午5:08 by with 0 comment

[Power Query] Advanced Editor 使用 IF 條件

要在 Advanced Editor 使用 if 語句,必須將 if 語句指定給變數。
例如要判斷 varQ 為 0 或 1,需用變數 connX 賦予其對應值。

let
    access = Excel.CurrentWorkbook(){[Name="pAccess"]}[Content]{0}[#"Access"],
    conn1 = 0,
    conn2 = 1,

    varQ = if access = "IN3" then conn1 else conn2,

    server = Excel.CurrentWorkbook(){[Name="pServer"]}[Content]{varQ}[#"Location"],
    db = Excel.CurrentWorkbook(){[Name="pServer"]}[Content]{varQ}[#"Data"],

    Source = Sql.Database(""& server &"", ""& db &"", [Query="exec dbo.Test_GetProduct",       CommandTimeout=#duration(0, 10, 0, 0)])

in
    Source

      edit

0 意見:

張貼留言