简体   繁体   English

如何在使用 VLOOKUP+QUERY+IMPORTRANGE 时应用多个条件?

[英]How to apply multiple criteria when using VLOOKUP+QUERY+IMPORTRANGE?

So, right now, the formula below successfully queries data from another file, butthis based on a column's data as the criteria.所以,现在,下面的公式成功地从另一个文件中查询数据,但这基于列的数据作为条件。 The need is to have more than one criteria and I'm not sure if thecolumn to be compared against needs to come in as an additional query, together with the first query...so I'm lost here.需要有多个条件,我不确定要比较的列是否需要作为附加查询与第一个查询一起出现……所以我在这里迷路了。

This is the formula I'm using:这是我使用的公式:

=Arrayformula(
   if(F9:F="";"";
      vlookup(A9:A;
         QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/xxxxXXXXXXXxxxxxXXXX/edit";"Costura!A1:R"); 
         "select Col6, Col8, Col14";0)
      ;2;0)
    )
 )

Here's a sample file with dummy data !这是一个带有虚拟数据的示例文件

For a system like this, the best practice is just to import the entirety of the imported data in a tab of it's own, then run a vlookup to that tab using "both" criteria.对于这样的系统,最佳做法是将全部导入数据导入到它自己的选项卡中,然后使用“两个”条件对该选项卡运行 vlookup。 This will simplify your formulas and also does not increase processing time at all.这将简化您的公式,并且根本不会增加处理时间。 Just hide the "naked" import tab.只需隐藏“裸”导入选项卡。

I will demonstrate on your sample sheet in two tabs beginning with "MK".我将在您的样本表中以两个以“MK”开头的选项卡进行演示。

but the basic idea is an ampersanded (&'ed) [search key] in your VLOOKUP()但基本思想是在您的 VLOOKUP()

=ARRAYFORMULA(IFERROR(VLOOKUP(A6:A&B6:B,{MK_Data!A:A&MK_Data!H:H,MK_Data!J:J},2,0)))

can be done like this:可以这样做:

=ARRAYFORMULA(IF(B6:B="",,IFNA(VLOOKUP(A6:A&B6:B, 
 {QUERY(Data!A1:J, "select A", 0)&
  QUERY(Data!A1:J, "select H", 0), 
  QUERY(Data!A1:J, "select J", 0)}, 2, 0))))

which will translate into this:这将转化为:

=ARRAYFORMULA(IF(B6:B="",,IFNA(VLOOKUP(A6:A&B6:B, 
 {IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Data!A:A")&
  IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Data!H:H"), 
  IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Data!J:J")}, 2, 0))))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM