Getting IDs based on multiple string criteria

时间:2015-10-29 15:45:35

标签: excel excel-formula match

Following data structure:

ID   CRIT1    CRIT2
1    L        M
2    H        M
3    H        H

I would like to get the IDs with Crit1= H and Crit2=H. In a second sheet I want to build a table with the IDs which satisfy my criteria. So in this case only 3.

I tried with INDEX/MATCH and COUNTIF.

However, so far no useful solution based on strings and ranges.

5 个答案:

答案 0 :(得分:1)

I suggest a PivotTable without Totals or Subtotals, in Tabular Form, all three columns as ROWS and filtered to select H for each of CRIT1 and CRIT2:

SO33418793 example

答案 1 :(得分:1)

这是一个公式解决方案,可以创建没有任何空白的表格。

这假设您的源数据在Sheet1中。根据需要进行编辑。

=IFERROR(INDEX(Sheet1!A$2:A$9999,SMALL(IF((Sheet1!B$2:B$9999="H")*(Sheet1!C$2:C$9999="H"),ROW(Sheet1!A$2:A$9999),9E+99),ROW(1:1))-1),"")
  

这是一个数组公式,必须使用 Ctrl + Shift + Enter 确认。

现在根据需要复制下来。

注意:将9999调整为适合您情况的行号。

答案 2 :(得分:0)

如果没有宏,您只能在满足条件时复制单个单元格,否则不复制它们。将此公式粘贴到A2中,然后将其复制到右侧(其他列)和底部(其他行):

=IF(AND(Sheet1!$B2="H";Sheet1!$C2="H");Sheet1!A2;"")

答案 3 :(得分:0)

好的,所以数据透视表确实有效,但是我想绘制一个使用数据透视数据模型似乎不可能的图表

enter image description here

答案 4 :(得分:0)

关于配方​​解决方案,我认为它不起作用。 enter image description here

它会给我所有ID为crit1 = h或crit2 = h