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中的表进行分组->使用产品名称作为键合并两个查询(现在每个查询上只有唯一的值)->在合并的查询中展开名称表
| 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,我认为需要对每个副本进行计数和编号;现在我假设,如果行数不相同,则需要进行计数和编号。是的,不同的表大小会更痛苦。