从数组的 Index/Match 中查找匹配的最低值

Find lowest value matched from an Index/Match of an array

Example Spreadsheet

当前公式未 return 需要的值:

=IFERROR(ifNA(min(arrayformula(index(D2:I2, match(INDEX(FLATTEN(split(A2, ", ", FALSE)&" "&TRANSPOSE(split(B2, ", ", FALSE)))), D:I, 0)))), "Role not at Facility"), "")

A 列包含逗号分隔的位置列表,B 列是角色列表。

我想检查单个位置到单个角色的所有组合。 arrayformula(FLATTEN(split(A2, ", ", FALSE)&" "&TRANSPOSE(split(B2, ", ", FALSE)))) 足够好地为我提供了所有组合的数组。

我希望有一种方法可以将该数组馈送到 index/match 中,将 return 所有匹配值放入一个数组中,这样我就可以将其包装在 min() 中并获得数组的最低值作为我的最终目标。

我的示例 sheet 显示了我遇到的一些问题,最明显的是唯一得到评估的 location/role 组合是第一个。

当前状态(% Credentialed 列中的公式)

Location Credentialing For Role Credentialing For % Credentialed VALLEY ROLE 1 VALLEY ROLE 2 VALLEY ROLE 3 MISSION ROLE 1 MISSION ROLE 3 RIVER ROLE 2
MISSION, RIVER ROLE 1, ROLE 3 100.00% 88.24% 94.74% 94.74% 100.00% 88.24% 88.24%
MISSION, VALLEY, RIVER ROLE 2 Role not at Facility 15.00% 20.00% 60.00% 80.00% 100.00% 16.00%
VALLEY, MISSION ROLE 2, ROLE 1 88.00% 100.00% 88.00% 20.00% 15.00% 20.00% 50.00%

想要return

Location Credentialing For Role Credentialing For % Credentialed VALLEY ROLE 1 VALLEY ROLE 2 VALLEY ROLE 3 MISSION ROLE 1 MISSION ROLE 3 RIVER ROLE 2
MISSION, RIVER ROLE 1, ROLE 3 88.25% 88.24% 94.74% 94.74% 100.00% 88.24% 88.24%
MISSION, VALLEY, RIVER ROLE 2 16.00% 15.00% 20.00% 60.00% 80.00% 100.00% 16.00%
VALLEY, MISSION ROLE 2, ROLE 1 15.00% 100.00% 88.00% 20.00% 15.00% 20.00% 50.00%

尝试:

=FLATTEN(INDEX(QUERY(IFNA(VLOOKUP(QUERY(SPLIT(FLATTEN(TRANSPOSE(FLATTEN(
 ROW(A2:A5)&"×"&ROW(A2:A5)&SPLIT(A2:A5, ", ", )))&" "&
 FLATTEN(SPLIT(B2:B5, ", ", )&"×"&ROW(B2:B5))), "×"), 
 "select max(Col2) 
  where Col1=Col3 
    and not Col2 matches '^\d+ .*|.* $' 
    and Col1 is not null 
  group by Col2 
  pivot Col3"), SPLIT(FLATTEN(ROW(A2:A5)&D1:I1&"×"&D2:I5), "×"), 2, 0)), 
 "select "&TEXTJOIN(",", 1, 
 "min(Col"&ROW(A2:A5)-(ROW(A2)-1)&")")), 2))

demo sheet with step by step formula explanation

将上面的答案保留为官方答案,但补充说,如果不需要数组结果,例如对于定期更新的足够大的数据集并且会受到这样的影响,我使用上面的答案来降低以下也适用:

=min(ArrayFormula(IFNA(ArrayFormula(VLOOKUP(FLATTEN(ArrayFormula(TRANSPOSE(flatten(SPLIT(A2, ", ", )))&" "&Transpose(SPLIT(B2, ", ", )))), ArrayFormula(SPLIT(FLATTEN(ArrayFormula(D1:I1&"×"&D2:I2)), "×")), 2, 0)))))    

请参阅 player0 对上述数组 return 版本的回答。