gpt4 book ai didi

mysql - Power BI 查询 : Need to Select Columns in Table 1 based on list of column names in Table 2

转载 作者:行者123 更新时间:2023-11-29 15:28:19 25 4
gpt4 key购买 nike

我使用 power query 将两个表(表#1 和表#2)中的数据合并到单个主数据表(表#3)中。表#4 和表#5 分别包含表#1 和表#2 中的列名称列表,我希望将其包含在表#3 中。我已将这两个表作为“仅连接表”插入到 power query 中。

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

我正在尝试在高级查询编辑器的 Table.SelectColumns 函数中执行表 #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
.. ..

关于mysql - Power BI 查询 : Need to Select Columns in Table 1 based on list of column names in Table 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58915907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com