Countifs matching two separate tables

Melimob

Active Member
Joined
Oct 16, 2011
Messages
395
Office Version
  1. 365
Hi

I have this formula but stuck on the last condition.

I want to count based on Client Name in current table where it finds a match to:
table1 client name
& is not OOS/Lost
AND
if the country is listed both on table1 matching a table in another sheet which is called 'Prority 1'

this last bit is where I'm stuck? Grateful for advice! thank you!

=COUNTIFS(Table1[POA / Clients],"*"&[Client Name]&"*",Table1[OOS / Lost],"<>OOS",Table1[OOS / Lost],"<>LOST",Table1[Country],Priority_1)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hey, I'd append your COUNTIFS formula with a SUMPRODUCT, close off the COUNTIFS after your final working constraint (Table1[OOS / Lost],"<>LOST")
and add +SUMPRODUCT(--([@Country]=Table2[Priority 1]))
Replace Table2 with the other tables name and Priority 1 I have assumed to be the column name - basically reference the table column from the other sheet. Make sure you use this formula in correlation with your main tables rows as it uses structured referencing.

Full formula:
=COUNTIFS(Table1[POA / Clients],"*"&[Client Name]&"*",Table1[OOS / Lost],"<>OOS",Table1[OOS / Lost],"<>LOST") + SUMPRODUCT(--([@Country]=Table2[Priority 1]))
 
Last edited:
Upvote 0
Hey, I'd append your COUNTIFS formula with a SUMPRODUCT, close off the COUNTIFS after your final working constraint (Table1[OOS / Lost],"<>LOST")
and add +SUMPRODUCT(--([@Country]=Table2[Priority 1]))
Replace Table2 with the other tables name and Priority 1 I have assumed to be the column name - basically reference the table column from the other sheet. Make sure you use this formula in correlation with your main tables rows as it uses structured referencing.

Full formula:
=COUNTIFS(Table1[POA / Clients],"*"&[Client Name]&"*",Table1[OOS / Lost],"<>OOS",Table1[OOS / Lost],"<>LOST") + SUMPRODUCT(--([@Country]=Table2[Priority 1]))

Hi Tyija

Firstly thank you so much for your reply... so it's semi working but giving a value error for first two rows then giving wrong value for the remaining. I think this is what you were talking about correlation with main tables but I don't know how to fix?

I've tried:
=COUNTIFS(Table1[POA / Clients],"*"&[@[Client Name]]&"*",Table1[OOS / Lost],"<>OOS",Table1[OOS / Lost],"<>LOST") + SUMPRODUCT(--(Table1[@Country]=Table47[Priority 1]))

so Table1 data starts on row 8
Table47 data starts on row 2
and the table which I'm entering the formula in starts on row 6
Unfortunately row 5 has 'Strategic' in under client name and then the rest of that row is blank -does this matter?

Client Name
STRATEGIC
ABC

<colgroup><col></colgroup><tbody>
</tbody>

thank you for any advice!
 
Upvote 0
Hey,

So there are 3 tables? Then the last formula (SUMPRODUCT) will most likely be the issue now as it is using a structured reference from table 1 (so has to be written alongside the table if you will) - that's probably why the errors are for the first 2 rows (6 & 7) then as the table 1 starts on row 8 you get different messages from row 8 onwards. It's hard to visualise this with a 3rd table, have you got some link to the file?
 
Upvote 0
Hey,

So there are 3 tables? Then the last formula (SUMPRODUCT) will most likely be the issue now as it is using a structured reference from table 1 (so has to be written alongside the table if you will) - that's probably why the errors are for the first 2 rows (6 & 7) then as the table 1 starts on row 8 you get different messages from row 8 onwards. It's hard to visualise this with a 3rd table, have you got some link to the file?

waa sorry for this.

so here's how it's set up as an example:

sheet lkups:

Table47 data starts on row 2
Priority 1
Bosnia
Croatia
El Salvador
Greece

<tbody>
</tbody>

sheet Project Timelines
so Table1 data starts on row 8

CountryClient CountPOA / ClientsOOS / Lost
AngolaClients (0)XXX Partner
AngolaABCOOS
BosniaABC

<tbody>
</tbody>


sheet Top Clients
(this is where the formula is returning the value)
Table16 starts on row 6 (row 5 has strategic)

Client NamePriority 1
2019
STRATEGIC
ABC#VALUE!

<tbody>
</tbody>


I want to match against the client in table 16 and count them from Table 1 as long as they're not 'OOS' 'Lost' and only if the country is matched on table47 priorty1 (lkups tab)

=COUNTIFS(Table1[POA / Clients],"*"&[@[Client Name]]&"*",Table1[OOS / Lost],"<>OOS",Table1[OOS / Lost],"<>LOST") + SUMPRODUCT(--(Table1[@Country]=Table47[Priority 1]))

so in above example it should return value as 1 since bosnia and ABC are on the list and are not marked as OOS/Lost

complicated or what!? :)

 
Last edited:
Upvote 0
This has blown my brain and I can't think how to do this right now! I am sure there would be a way but I can't think what it is unfortunately...
 
Upvote 0
Try in the second column of Table16

=SUMPRODUCT(ISNUMBER(SEARCH([@[Client Name]],Table1[POA / Clients]))*(Table1[OOS / Lost]<>"OOS")*(Table1[OOS / Lost]<>"LOST")*ISNUMBER(MATCH(Table1[Country],Table47[Priority 1],0)))

Hope this helps

M.
 
Last edited:
Upvote 0
Try in the second column of Table16

=SUMPRODUCT(ISNUMBER(SEARCH([@[Client Name]],Table1[POA / Clients]))*(Table1[OOS / Lost]<>"OOS")*(Table1[OOS / Lost]<>"LOST")*ISNUMBER(MATCH(Table1[Country],Table47[Priority 1],0)))

Hope this helps

M.


Thank you so much Marcelo that works great!

erm, my only fear is sometimes the country on table 1 is inputted with other text. In most of my other formulas reading this column I've had to do 'contains' rather than 'exact match'.
It works ok for now since all the countries listed are using correct format but in case anyone adds in other text, is there any way to adapt the below for 'contains'?

=SUMPRODUCT(ISNUMBER(SEARCH([@[Client Name]],Table1[POA / Clients]))*(Table1[OOS / Lost]<>"OOS")*(Table1[OOS / Lost]<>"LOST")*ISNUMBER(MATCH(Table1[Country],Table47[Priority 1],0)))

thank you thank you thank you again though to you both!
 
Upvote 0
You are welcome. Thanks for the feedback.

my only fear is sometimes the country on table 1 is inputted with other text. In most of my other formulas reading this column I've had to do 'contains' rather than 'exact match'.

Try
=SUMPRODUCT(ISNUMBER(SEARCH(Table16[@[Client Name]],Table1[POA / Clients]))*(Table1[OOS / Lost]<>"OOS")*(Table1[OOS / Lost]<>"LOST")*ISNUMBER(MATCH("*"&Table1[Country]&"*",Table47[Priority 1],0)))

M.
 
Upvote 0
You are welcome. Thanks for the feedback.



Try
=SUMPRODUCT(ISNUMBER(SEARCH(Table16[@[Client Name]],Table1[POA / Clients]))*(Table1[OOS / Lost]<>"OOS")*(Table1[OOS / Lost]<>"LOST")*ISNUMBER(MATCH("*"&Table1[Country]&"*",Table47[Priority 1],0)))

M.

Hi Marcelo

Thank you again for trying to help me.

Unfortunately that didn't work :(

It's ok though, I'll try and advise them that they need to ensure Table1 only has the country name and nothing else.

thank you again!
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top