Vlookup AND 检查单元格是否包含其他条件
Vlookup AND check if cell contains other critera
我有一个 Google Sheet,其中包含以下选项卡:
Shops
||这包含一些下拉菜单
!Data_ShopInventory
||这包含 A-I 列,实际上是 'database'
!Data_Shops
||这包含一些基于其他选项卡随机生成的东西,然后商店选项卡从中提取
我有以下公式:
={"Items";SORTN(FILTER('!Data_ShopInventory'!$A:$A, SEARCH(Shops!$C, '!Data_ShopInventory'!$I:$I)), 5, 0, ARRAYFORMULA(RANDBETWEEN(TRANSPOSE(SPLIT(REPT("1,",COUNTA(FILTER('!Data_ShopInventory'!$A:$A, search(Shops!$C, '!Data_ShopInventory'!$I:$I)))), ",", 0, 1)), 10000)), 1)}
这是这样工作的:根据 select 在 Shops
选项卡(单元格 C3)上编辑的下拉菜单,它将随机从 !Data_ShopInventory
中拉出 5 个项目(A 列)选项卡。
在 !Data_ShopInventory
选项卡中,我有一列(城镇规模),其中包含如下文本:
- 大
- 中
- 中号,大号
- 小,中
- 小
- 小、中、大
我需要让我的 vlookup returns 随机项目也考虑到这一点。
在 Shops
选项卡上,还有另一个下拉菜单(单元格 C4),其中包含小、中或大选项。
因此,如果我 select 'Large',我希望 vlookup 仅 return C3 匹配的随机项目(就像它目前在上面的公式中所做的那样)和相应的单元格Col G 中包含 C4 中下拉列表中的 selection。
试了很多,我就是想不通... 1:30am,我累了。有人能帮忙吗?
这里是 link 到 sheet:
Google Sheet Copy
删除 G1:J1 并在 G1 中使用:
={"Standard Price", "Discounted Price", "Inflated Price", "Limited Stock";
ARRAYFORMULA(IF(LEN(F2:F), IFNA(VLOOKUP(F2:F,
FILTER('!Data_ShopInventory'!A:H, REGEXMATCH('!Data_ShopInventory'!G:G, Shops!C4)), {3,4,5,8}, )), ))}
更新:
={"Items";SORTN(FILTER('!Data_ShopInventory'!$A:$A, SEARCH(Shops!$C, '!Data_ShopInventory'!$I:$I),REGEXMATCH('!Data_ShopInventory'!G2:G, Shops!C4)), 30, 0, ARRAYFORMULA(RANDBETWEEN(TRANSPOSE(SPLIT(REPT("1,",COUNTA(FILTER('!Data_ShopInventory'!$A:$A, search(Shops!$C, '!Data_ShopInventory'!$I:$I),REGEXMATCH('!Data_ShopInventory'!G2:G, Shops!C4)))), ",", 0, 1)), 10000)), 1)}
if I select 'Large', I want the vlookup to only return random items where C3 matches (like it currently does in the above formula) and where the corresponding cell in Col G contains the selection from the drop-down in C4.
因此,如果我理解正确的话,您想要 return 来自 !Data_ShopInventory
的五个随机项目,其中 ShopType
匹配 Shops!C3
,TownSizeAvailable
匹配 Shops!C4
。如果这就是您所追求的,这个公式可以解决问题。
={"Items";SortN(Query('!Data_ShopInventory'!A2:I,"select A where I='"&Shops!C3&"' and G like '%"&Shops!C4&"%'",0),5,,RandArray(SumProduct(('!Data_ShopInventory'!I2:I=Shops!C3)*RegexMatch('!Data_ShopInventory'!G2:G,Shops!C4))),0)}
我有一个 Google Sheet,其中包含以下选项卡:
Shops
||这包含一些下拉菜单!Data_ShopInventory
||这包含 A-I 列,实际上是 'database'!Data_Shops
||这包含一些基于其他选项卡随机生成的东西,然后商店选项卡从中提取
我有以下公式:
={"Items";SORTN(FILTER('!Data_ShopInventory'!$A:$A, SEARCH(Shops!$C, '!Data_ShopInventory'!$I:$I)), 5, 0, ARRAYFORMULA(RANDBETWEEN(TRANSPOSE(SPLIT(REPT("1,",COUNTA(FILTER('!Data_ShopInventory'!$A:$A, search(Shops!$C, '!Data_ShopInventory'!$I:$I)))), ",", 0, 1)), 10000)), 1)}
这是这样工作的:根据 select 在 Shops
选项卡(单元格 C3)上编辑的下拉菜单,它将随机从 !Data_ShopInventory
中拉出 5 个项目(A 列)选项卡。
在 !Data_ShopInventory
选项卡中,我有一列(城镇规模),其中包含如下文本:
- 大
- 中
- 中号,大号
- 小,中
- 小
- 小、中、大
我需要让我的 vlookup returns 随机项目也考虑到这一点。
在 Shops
选项卡上,还有另一个下拉菜单(单元格 C4),其中包含小、中或大选项。
因此,如果我 select 'Large',我希望 vlookup 仅 return C3 匹配的随机项目(就像它目前在上面的公式中所做的那样)和相应的单元格Col G 中包含 C4 中下拉列表中的 selection。
试了很多,我就是想不通... 1:30am,我累了。有人能帮忙吗?
这里是 link 到 sheet: Google Sheet Copy
删除 G1:J1 并在 G1 中使用:
={"Standard Price", "Discounted Price", "Inflated Price", "Limited Stock";
ARRAYFORMULA(IF(LEN(F2:F), IFNA(VLOOKUP(F2:F,
FILTER('!Data_ShopInventory'!A:H, REGEXMATCH('!Data_ShopInventory'!G:G, Shops!C4)), {3,4,5,8}, )), ))}
更新:
={"Items";SORTN(FILTER('!Data_ShopInventory'!$A:$A, SEARCH(Shops!$C, '!Data_ShopInventory'!$I:$I),REGEXMATCH('!Data_ShopInventory'!G2:G, Shops!C4)), 30, 0, ARRAYFORMULA(RANDBETWEEN(TRANSPOSE(SPLIT(REPT("1,",COUNTA(FILTER('!Data_ShopInventory'!$A:$A, search(Shops!$C, '!Data_ShopInventory'!$I:$I),REGEXMATCH('!Data_ShopInventory'!G2:G, Shops!C4)))), ",", 0, 1)), 10000)), 1)}
if I select 'Large', I want the vlookup to only return random items where C3 matches (like it currently does in the above formula) and where the corresponding cell in Col G contains the selection from the drop-down in C4.
因此,如果我理解正确的话,您想要 return 来自 !Data_ShopInventory
的五个随机项目,其中 ShopType
匹配 Shops!C3
,TownSizeAvailable
匹配 Shops!C4
。如果这就是您所追求的,这个公式可以解决问题。
={"Items";SortN(Query('!Data_ShopInventory'!A2:I,"select A where I='"&Shops!C3&"' and G like '%"&Shops!C4&"%'",0),5,,RandArray(SumProduct(('!Data_ShopInventory'!I2:I=Shops!C3)*RegexMatch('!Data_ShopInventory'!G2:G,Shops!C4))),0)}