首页 > 解决方案 > VLOOK Excel 结果与 Power Query 合并不匹配

问题描述

  1. 我创建了 Power 查询以使用合并对两个表执行 VLOOK。
  2. 当我使用 Full Outer 合并它们时,结果与 VLOOKUP Excel 不同。

似乎 Excel VLOOKUP 公式采用第一个匹配实例并且没有更进一步。

Table2 
Apple 2 fruit
Grapes 14 fruit
Grapes 15 fruit
Grapes 16 fruit
Banana 22 fruit
Banana 23 fruit
Banana 24 fruit
Banana 25 fruit

Table1
prod sno (VLOOKUP)
Apple 1
Grapes 14
Grapes 14
Banana 22
Banana 22

=VLOOKUP(A2,Table2[#All],2,FALSE)

let
Source = Table.NestedJoin(Table4, {"prod"}, Table2, {"prod"}, "Table2", JoinKind.LeftOuter),
#"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {"snum"}, {"Table2.snum"})
in
#"Expanded Table2"

RESULT FROM PQ FOR VLOOKUP

prod Table2.snum
Apple 1
Apple 2
Grapes 14
Grapes 15
Grapes 16
Grapes 14
Grapes 15
Grapes 16
Banana 22
Banana 22
Banana 23
Banana 23
Banana 24
Banana 24
Banana 25
Banana 25

标签: excelvlookuppowerquery

解决方案


删除您已在使用的展开步骤。假设 XXX 是合并步骤中的列名,添加添加列...自定义列...与公式

= Table.FirstN([XXX],1)

然后右键单击列 XXX 并将其删除。而是展开新列

这只会从合并中获取一个结果,即第一行


推荐阅读