【问题标题】:Power BI Query: Need to Select Columns in Table 1 based on list of column names in Table 2Power BI 查询:需要根据表 2 中的列名列表选择表 1 中的列
【发布时间】:2019-11-18 13:39:35
【问题描述】:

我已使用电源查询将两个表(表#1 和表#2)中的数据合并到单个主数据表(表#3)中。 表#4 和表#5 分别包含表#1 和表#2 中的列名列表,我想将它们包含在表#3 中。我已将这两个表作为“仅连接表”插入到电源查询中。

我希望每次更新表 #4 和/或表 #5 时动态更新电源查询,而不是每次手动执行此操作。

我正在尝试在高级查询编辑器的 Table.SelectColumns 函数中执行此表 #4 和表 #5 查询来执行此操作。如果是这样,请帮助并分享解决方案代码。

提前致谢。

【问题讨论】:

    标签: mysql sql powerbi powerquery advanced-query-tool


    【解决方案1】:

    不是 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
    ..          ..
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-21
      相关资源
      最近更新 更多