簡體   English   中英

Power BI 查詢:需要 Select 表 1 中的列基於表 2 中的列名列表

[英]Power BI Query: Need to Select Columns in Table 1 based on list of column names in Table 2

我使用電源查詢將兩個表(表#1 和表#2)中的數據合並到單個主數據表(表#3)中。 表#4 和表#5 分別包含表#1 和表#2 中的列名列表,我想將它們包含在表#3 中。 我已將這兩個表作為“僅連接表”插入到電源查詢中。

而不是每次我希望每次更新表#4和/或表#5時動態更新電源查詢時手動執行此操作。

我正在嘗試在高級查詢編輯器中的 Table.SelectColumns function 中執行此表 #4 和表 #5 查詢來執行此操作。 如果是這樣,請幫助並分享解決方案代碼。

提前致謝。

不是 100% 確定我了解您的需求,但我已經嘗試過了。

假設您的Table_4如下所示:

Column_name
Row_Update
Row_ID

單擊 Power Query 中的轉換為列表Table_4現在將是一個列表[Row_update, Row_ID]

Table_1如下所示:

Name  Value  Row_Update  Row_ID
'a'   10     2019        1
..    ..     ..          ..

Table_1的查詢中,您現在可以在 SelectColumns 中使用此列表,如下所示:

let
    Source = Sql.Databases("localhost"),
    my_db = Source{[Name="my_db"]}[Data],
    Table_1 = my_db{[Schema="my_schema",Item="Table_1"]}[Data],
    // have manually modified the code Remove Other Columns created
    // replacing the selected columns with a reference to the list
    #"Remove Other Columns" = Table.SelectColumns(Table_1,#"Table_4")
in
    #"Remove Other Columns"

現在Table_1將如下所示:

Row_Update  Row_ID
2019        1
..          ..

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM