Countifs not working due to range ? maybe an array?

mtleigh

New Member
Joined
Aug 13, 2012
Messages
11
Hi and good afternoon,
I am struggling to get a formula for countifs to work and i beleive this is due to my criteria ranges not being of the same size. Is there any work around to this?

i have put my example below but the actual data set is much larger but i have the same problem. the data set contains 15k rows and the worksheet is approx 25 columns in width.

1675864181561.png


so i have a table showing customer acc number and the service codes that may have been carried out throughout the year per customer per consignment hence why the same customer number may appear more than once. In the example above, the top table is my data set and the bottom of the 2 tables is a summary i am trying to get to work. I have tried named ranges instead of selecting the columns but this does not work either. If i try countif and count only the number of times the ACC appears it works, if i try countif to see how many times the service code appears, that also works, but i cannot get both to work in tandem using the countifs formula. I did read that both criteria ranges need to be of the same size. i did try then extending my acc criteria range to match the same number of columns but then it was only counting the first column of the service code range and not the other columns. Can anybody help?
 

Attachments

  • 1675863444687.png
    1675863444687.png
    32.9 KB · Views: 14

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
try SUMPRODUCT()

excel forum-ETAF.xlsx
ABCDE
1
211a1b1a
321b1c1a
411c1a
521a1b1a
611b1c1a
7
8
9
10
11
12
13
14
15
16
171a1b1c
181422
192321
20
21
Sheet2
Cell Formulas
RangeFormula
B18:D19B18=SUMPRODUCT(($B$2:$D$6=B$17)*($A$2:$A$6=$A18))
 
Upvote 0
How about
Excel Formula:
=SUMPRODUCT(($B$3:$F$10=C$15)*($A$3:$A$10=$A17))
 
Upvote 0
this works inmy example thankyou, however it does not work inmy dataset and i am unclear why. could it have anything to do with the service codes being a result of a formula and not a value on its own?
 
Upvote 0
unlikely
but this quickly comes to mind

are the headings text - exactly the same as the text - no spaces
any issue where the numbers at the side are text in 1 table and not in another

Note: Images are difficult to see , and also requires that I input all the data myself, which means I may make an error, which is very time consuming, and from my point of view less likely to get a response, if a complicated spreadsheet. Plus we cannot see any of the formulas used.

Therefore -

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC , then put the sample spreadsheet onto a share
I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed
 
Upvote 0
do something like - where you expect a match

cell=cell
for both the account and the Service text

like F2 and G2 - in my example here

Book4
ABCDEFG
1TEST - acctest Service
211a1b1aTRUETRUE
321b1c1a
411c1a
521a1b1a
611b1c1a
7
8
9
10
11
12
13
14
15
16
171a1b1c
181422
192321
20
Sheet1
Cell Formulas
RangeFormula
F2F2=A2=A18
G2G2=B2=B17
B18:D19B18=SUMPRODUCT(($B$2:$D$6=B$17)*($A$2:$A$6=$A18))
 
Upvote 0
if they were in different formats then the countif formulas wouldnt work in the first place would they? as some of them are formula results they cannot be in text format and if i go to format cells on the summary sheet they are showing in 'General' format??

i think i have provided a link to Dropbox but not sure if it will work:


basically the sheet named 'By Shipto' in red needs summarisind as per by example earlier displayed. from the Data import sheet it is columns S:Z containing the codes which i need counting byt the ACC number which is in column B
 
Upvote 0
How about
Excel Formula:
=SUMPRODUCT((Report[[SC1]:[SC10]]=D$2)*(Report[[Shipto]:[Shipto]]=$A4))
 
Upvote 0
i get it to work if i use the sheet name and range
=SUMPRODUCT(('Data Import'!$C$2:$L$20=D$2)*('Data Import'!$B$2:$B$20=$A4))

not sure what happens with the table references - when i include row 20 - it changes
to table reference
=SUMPRODUCT((Report[[SC1]:[SC10]]=D$2)*(Report[Shipto]=$A4))
But then returns zero

Not an expert at tables - and often have issues when referencing tables - i change to old reference sheet!range and usually get it to work

But no idea

will only be on dropbox for a couple of days
 
Upvote 1
Solution

Forum statistics

Threads
1,224,750
Messages
6,180,740
Members
452,996
Latest member
nelsonsix66

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