Countif(s) or similar using data from different tables

hphillips

New Member
Joined
Nov 1, 2017
Messages
3
Hi all,

Hopefully someone can help me with this because it's driving me mad.

I have two tables on separate sheets. The first holds a list of cases and who managed the case (and how long it was open, but that one is less relevant for now). The second has a list of staff that appear in the first table and their location (UK/US).

e.g. Table 1
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Case Number[/TD]
[TD]Owner[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Jane[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Joe[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Sarah[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Sarah[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Harry[/TD]
[/TR]
</tbody>[/TABLE]

Table 2
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Location[/TD]
[/TR]
[TR]
[TD]Harry[/TD]
[TD]UK[/TD]
[/TR]
[TR]
[TD]Jane[/TD]
[TD]UK[/TD]
[/TR]
[TR]
[TD]Joe[/TD]
[TD]US[/TD]
[/TR]
[TR]
[TD]Sarah[/TD]
[TD]US[/TD]
[/TR]
</tbody>[/TABLE]


What I want to be able to get is the number of cases in each location - and ideally I'd just be able to drop fresh data in my table of cases and have the totals 'magically' recalculate.

Obviously I can do it quite simply if I add a VLookup to the location on the first table and then just use CountIf, but I'd like to avoid this step if possible as once I've set it up this will be handed over to other people to manage.

Are there any solutions out there?

Thanks.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi, welcome to the board!

Here is one option you could try:


Excel 2013/2016
ABCDEFGH
1CaseOwnerNameLocationLocCount
21JaneHarryUKUK2
32JoeJaneUKUS3
43SarahJoeUS
54SarahSarahUS
65Harry
Sheet2
Cell Formulas
RangeFormula
H2=SUMPRODUCT(--ISNUMBER(MATCH($B$2:$B$6&"|"&G2,$D$2:$D$5&"|"&$E$2:$E$5,0)))
 
Last edited:
Upvote 0
You should be able to work this backwards from the Name/Location table:


Book1
AB
1Case NumberOwner
21Jane
32Joe
43Sarah
54Sarah
65Harry
7
8NameLocation
9HarryUK
10JaneUK
11JoeUS
12SarahUS
13
14UK2
15US3
Sheet4
Cell Formulas
RangeFormula
B14{=SUM(IF($B$9:$B$12=$A14,COUNTIF($B$2:$B$6,$A$9:$A$12)))}
Press CTRL+SHIFT+ENTER to enter array formulas.


WBD
 
Upvote 0
Thanks both of you.

Unfortunately both of these solutions only work if I put in exact cell references which would mean updating the formulas each time as we won't have the same amount of data in each report.
 
Upvote 0
Unfortunately both of these solutions only work if I put in exact cell references which would mean updating the formulas each time as we won't have the same amount of data in each report.

Hi, you have several options.

1. Use tables and structured references (my preference)
2. Simply extend the ranges used by the formula's to sensible maximums
3. Use dynamic named ranges
 
Upvote 0
Hi, you have several options.

1. Use tables and structured references (my preference)
2. Simply extend the ranges used by the formula's to sensible maximums
3. Use dynamic named ranges

Thanks!

I've got it working with dynamic named ranges so that's something.

I'll have a play with structured references and see if I can get that working too.
 
Upvote 0
Make sure both tables are formatted as table. Then create a pivot table in which you point to both tables. Excel will ask you to define a relationship between both tables.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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