Array formula with multiple Countifs

neodjandre

Well-known Member
I am using this formula which works fine:

=IF(ROWS(K\$62:K62)>SUM(COUNTIFS(accounts_table[§],{"P","B"})),"",INDEX(accounts_table[Account Name],SMALL(IF(ISNUMBER(MATCH(accounts_table[§],{"P","B"},0)),ROW(accounts_table[§])-ROW(INDEX(accounts_table[§],1,1))+1),ROWS(\$K\$62:K62))))

However, I need to add another COUNTIFS criteria:

COUNTIFS(accounts_table[§],{"P","B"},accounts_table[on],"On")

If I only make this change, the function doesn't work as expected. I presume I also need to change the second part of the function but can't figure out how.

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

neodjandre

Well-known Member
It it helps now, this is the structure of my spreadsheet

col A col B col C
P on item1
P off item2
B on item3
J on item4
P on item5
B off item6

So in the above example the array formula should pick item1, item3,item5

Hope it makes sense

FormR

MrExcel MVP
Hi, try like this, committed with CTRL+SHIFT+ENTER.

Code:
``=IF(ROWS(K\$62:K62)>SUM(COUNTIFS(accounts_table[§],{"P","B"},accounts_table[on],"on")),"",INDEX(accounts_table[account name],SMALL(IF(accounts_table[on]="on",IF(ISNUMBER(MATCH(accounts_table[§],{"P","B"},0)),ROW(accounts_table[§])-ROW(INDEX(accounts_table[§],1,1))+1)),ROWS(\$K\$62:K62))))``

Marcelo Branco

MrExcel MVP
EDIT
I hadn't seen FormR's formula that used table references. Solution already provided!

Try

 A​ B​ C​ D​ E​ 1​ Header1​ Header2​ Header3​ List​ 2​ P​ on​ item1​ item1​ 3​ P​ off​ item2​ item3​ 4​ B​ on​ item3​ item5​ 5​ J​ on​ item4​ 6​ P​ on​ item5​ 7​ B​ off​ item6​ 8​

<tbody>
</tbody>

Array formula in E2 copied down
=IF(ROWS(E\$2:E2)>SUM(COUNTIFS(A\$2:A\$7,{"P","B"},B\$2:B\$7,"On")),"",INDEX(C\$2:C\$7,SMALL(IF(ISNUMBER(MATCH(A\$2:A\$7,{"P","B"},0)),IF(B\$2:B\$7="on",ROW(C\$2:C\$7)-ROW(C\$2)+1)),ROWS(E\$2:E2))))
Ctrl+Shift+Enter

M.

Last edited:

neodjandre

Well-known Member
Hi, try like this, committed with CTRL+SHIFT+ENTER.

Code:
``=IF(ROWS(K\$62:K62)>SUM(COUNTIFS(accounts_table[§],{"P","B"},accounts_table[on],"on")),"",INDEX(accounts_table[account name],SMALL(IF(accounts_table[on]="on",IF(ISNUMBER(MATCH(accounts_table[§],{"P","B"},0)),ROW(accounts_table[§])-ROW(INDEX(accounts_table[§],1,1))+1)),ROWS(\$K\$62:K62))))``

thanks this works as expected

Replies
5
Views
369
Replies
2
Views
41
Replies
7
Views
173
Replies
1
Views
102
Replies
3
Views
103

1,132,794
Messages
5,655,339
Members
418,190
Latest member
Timex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back