Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 在Power Query中合并两个查询而不复制行_Excel_Powerbi_Powerquery - Fatal编程技术网

Excel 在Power Query中合并两个查询而不复制行

Excel 在Power Query中合并两个查询而不复制行,excel,powerbi,powerquery,Excel,Powerbi,Powerquery,我尝试使用一列(其中包含重复值,尽管两个查询中相同值的重复量完全相同)作为键合并两个查询;但每当我展开合并表时,所有行都会得到两倍的重复项 我不是电源查询方面的专家,我尝试过几种方法,包括不同的连接技巧(左、全、右等),结果总是一样的 设置如下所示: | Name |Extension|Folder Path |Product Name|Destination Path| ImageID | |File1.jpg| .jpg |c:/someroute/| Produ

我尝试使用一列(其中包含重复值,尽管两个查询中相同值的重复量完全相同)作为键合并两个查询;但每当我展开合并表时,所有行都会得到两倍的重复项

我不是电源查询方面的专家,我尝试过几种方法,包括不同的连接技巧(左、全、右等),结果总是一样的

设置如下所示:

|   Name  |Extension|Folder Path  |Product Name|Destination Path|    ImageID    |
|File1.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-1.jpg|
|File1.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-2.jpg|
|File2.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-1.jpg|
|File2.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-2.jpg|
|File4.jpg|   .jpg  |c:/someroute/|  ProductB  |  c:/otherpath/ | productB-1.jpg|
|File3.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-1.jpg|
|File3.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-2.jpg|
|File3.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-3.jpg|
|File8.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-1.jpg|
|File8.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-2.jpg|
|File8.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-3.jpg|
|File9.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-1.jpg|
|File9.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-2.jpg|
|File9.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-3.jpg|
查询表1:

|   Name  |Extension|Folder Path  |Product Name|Destination Path|
|File1.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ |
|File2.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ |
|File4.jpg|   .jpg  |c:/someroute/|  ProductB  |  c:/otherpath/ |
|File3.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ |
|File8.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ |
|File9.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ |
查询表2:

|productid|productSKU|Product Name|                    ImageIDs                  |
|   0001  | sku0001  |  ProductA  |          productA-1.jpg, productA-2.jpg      |
|   0002  | sku0002  |  ProductB  |                  productB-1.jpg              |
|   0003  | sku0003  |  ProductC  |productC-1.jpg, productc-2.jpg, productc-3.jpg|
所需输出(我正在构建一个动态重命名函数,以重命名所有名为ImageID的文件:

|   Name  |Extension|Folder Path  |Product Name|Destination Path|    ImageID    |
|File1.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-1.jpg|
|File2.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-2.jpg|
|File4.jpg|   .jpg  |c:/someroute/|  ProductB  |  c:/otherpath/ | productB-1.jpg|
|File3.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-1.jpg|
|File8.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-2.jpg|
|File9.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-3.jpg|
简言之,我尝试过但没有成功的是:

  • 在查询2中将ImageID列拆分为行->然后使用Product Name作为键合并查询->展开合并查询中的ImageID列
  • 创建具有唯一产品名称值的第三个查询->将其他两个查询合并到新创建的->根据需要展开所需列
  • 首先使用Product Name as key->合并两个查询,然后展开合并查询中的ImageIDs列->将ImageIDs列拆分为行
  • 按产品名称对查询1中的表进行分组->使用产品名称作为键合并两个查询(现在每个查询上只有唯一的值)->在合并的查询中展开名称表
我猜我应该使用某种索引列来计算Product Name中值的重复,但我真的不知道这一点,也不明白为什么它不起作用,但上面的任何选项都会输出类似这样的结果:

|   Name  |Extension|Folder Path  |Product Name|Destination Path|    ImageID    |
|File1.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-1.jpg|
|File1.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-2.jpg|
|File2.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-1.jpg|
|File2.jpg|   .jpg  |c:/someroute/|  ProductA  |  c:/otherpath/ | productA-2.jpg|
|File4.jpg|   .jpg  |c:/someroute/|  ProductB  |  c:/otherpath/ | productB-1.jpg|
|File3.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-1.jpg|
|File3.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-2.jpg|
|File3.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-3.jpg|
|File8.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-1.jpg|
|File8.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-2.jpg|
|File8.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-3.jpg|
|File9.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-1.jpg|
|File9.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-2.jpg|
|File9.jpg|   .jpg  |c:/someroute/|  ProductC  |  c:/otherpath/ | productC-3.jpg|

正如我前面提到的,我正在尝试创建一个重命名函数,以便使用随机名称的文件获得它们所代表的产品的名称。

如果将
表2
拆分为新行后,假设
表1
的行数与
表1
相同,则索引列应该对此进行排序

  • 表2
    展开到新行
  • Product Name
    ImageId
    对展开的
    表2
    进行排序
  • 将索引列添加到
    表2
  • 产品名称和
    名称对
    表1
    进行排序
  • 将索引列添加到
    表1
  • 使用要匹配的索引列将
    表2
    合并到
    表1
  • 表2中展开
    ImageId

  • 无论是
    File1.jpg
    还是
    File2.jpg
    productA-1.jpg
    在同一行中,这都有关系吗?嗨@Alexis不,这都没有关系。知道它是否有关系会很有意思,但对于这个练习来说它没有。感谢@Alexis它做了这个把戏,我怀疑索引列,但没有新的一个常规索引列会将其排序为ut,我认为需要对每个副本进行计数和编号;现在我假设,如果行数不相同,则需要进行计数和编号。是的,不同的表大小会更痛苦。