Ignoring multiple blank criteria using countifs / sumifs

Exhale2020

New Member
Joined
Sep 30, 2018
Messages
13
Hi all,

I've trawled various forums looking for a solution to this problem without much luck.

My challenge is i'm trying to count a large dynamic range of cells using multiple criteria (4 criteria).

However, what I want to occur is when one (or any/all) of the criteria is blank, I want the formula to ignore that particular criteria (not search for 'blank' as it does now).

SeasonFW18
GenderMENS
DivisionCottons
BrandUnitsCC's
Oasissumifscountifs
Gapsumifscountifs
ZARAsumifscountifs
H&Msumifscountifs

<tbody>
</tbody>

In the above table, 'Brand', 'Season', 'Gender', 'Division'. Are all Criteria. If any or all of the criteria are blank, I want it to be ignored.
The brand list will be dynamic and changes regularly. The Season, Gender & Division will be treated as drop down menus which are dynamic.

The purpose is to return a count in the CC's column.


The table being searched looks like this:

SeasonGenderDivisionBrandItem NumberColourTotal
FW18MensBottomsH&Mxxx123black12
SS19WOMENSTOPSH&MXX1234WHITE4
FW18MENSCOTTONSZARAXXX22BLUE7
FW18MENSTOPSOASIS12342WHITE8
SS18MENSTOPSZARA56WHY2BLUE8
FW18MENSCOTTONSOASIS44HT53BLACK9
SS18WOMENSTOPSZARAXX1244BLUE10
FW18MENSTEESOASIS134GGORANGE12
FW18WOMENSCOTTONSZARAGHR381BLACK5

<tbody>
</tbody>

The field to count is 'Total'


I've tried a combination of Ifs and CountIFS to ignore when blank, but its extremely lengthy and most likely inefficient. The source data is up to 20,000 rows :eek:


I'd also like to do the same with a Sumifs formula.


All help is much appreciated!

Thanks
G

Version: Office 2013
PC
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
1. Do not refer to whole columns.

2. Do the following better?

=SUMIFS(total,brand,A7,season,IF(B1="","?*",B1),gender,IF(B2="","?*",B2),division,IF(B3="","?*",B3))

=COUNTIFS(brand,A7,season,IF(B1="","?*",B1),gender,IF(B2="","?*",B2),division,IF(B3="","?*",B3))


One last question Aladin, so i can apply the logic in future... What does "?*" mean?
 
Upvote 0
ABC
1SeasonFW18
2GenderMENS
3DivisionCottons
4
5
6BrandUnitsCC's
7Oasis91
8Gap00
9ZARA00
10H&M00

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

In B7 enter and copy down:

=SUMPRODUCT(SUMIFS(total,brand,A7,season,IF(B1="",season,B1),gender,IF(B2="",gender,B2),division,IF(B3="",division,B3)))

In C7 enter and copy down:

=SUMPRODUCT(COUNTIFS(brand,A7,season,IF(B1="",season,B1),gender,IF(B2="",gender,B2),division,IF(B3="",division,B3)))

Hi Aladin,
If I wanted to add another cell to exclude a particular criteria, let's say, something within the 'division' range. How would i add it to the formula?
Thanks!
 
Upvote 0
Hi Aladin,
If I wanted to add another cell to exclude a particular criteria, let's say, something within the 'division' range. How would i add it to the formula?
Thanks!

We have now in B3 Cottons. If B3 is left empty, we interpret that as ?*. How/where do you want to indicate an exclusion? Care to provide an exclusion example?
 
Upvote 0
We have now in B3 Cottons. If B3 is left empty, we interpret that as ?*. How/where do you want to indicate an exclusion? Care to provide an exclusion example?

Yes correct on the wildcard.

I'd add another cell titled 'Exclude Division' in A4 and the criteria 'cottons' in B4.

Hypothetical:
I can leave all other criteria blank, which would return all results and then enter 'cottons' in B4, to return everything excluding cottons.
 
Upvote 0
Yes correct on the wildcard.

I'd add another cell titled 'Exclude Division' in A4 and the criteria 'cottons' in B4.

Hypothetical:
I can leave all other criteria blank, which would return all results and then enter 'cottons' in B4, to return everything excluding cottons.


Book1
ABCDEFG
1SeasonGenderDivisionBrandItem NumberColourTotal
2FW18MensBottomsH&Mxxx123black12
3SS19WOMENSTOPSH&MXX1234WHITE4
4FW18MENSCOTTONSZARAXXX22BLUE7
5FW18MENSTOPSOASIS12342WHITE8
6SS18MENSTOPSZARA56WHY2BLUE8
7FW18MENSCOTTONSOASIS44HT53BLACK9
8SS18WOMENSTOPSZARAXX1244BLUE10
9FW18MENSTEESOASIS134GGORANGE12
10FW18WOMENSCOTTONSZARAGHR381BLACK5
Sheet2



Book1
ABC
1SeasonFW18
2GenderMENS
3Division
4Exclude DivisionCottons
5
6BrandUnitsCC's
7Oasis202
8Gap00
9ZARA00
10H&M00
Sheet1


B7 of Sheet1 must house:

=SUMIFS(total,brand,A7,season,IF(B1="","?*",B1),gender,IF(B2="","?*",B2),division,IF(B3="","?*",B3),division,"<>"&B4)

C7 of Sheet1must house:

=COUNTIFS(brand,A7,season,IF(B1="","?*",B1),gender,IF(B2="","?*",B2),division,IF(B3="","?*",B3),division,"<>"&B4)
 
Upvote 0
ABCDEFG
1SeasonGenderDivisionBrandItem NumberColourTotal
2FW18MensBottomsH&Mxxx123black12
3SS19WOMENSTOPSH&MXX1234WHITE4
4FW18MENSCOTTONSZARAXXX22BLUE7
5FW18MENSTOPSOASIS12342WHITE8
6SS18MENSTOPSZARA56WHY2BLUE8
7FW18MENSCOTTONSOASIS44HT53BLACK9
8SS18WOMENSTOPSZARAXX1244BLUE10
9FW18MENSTEESOASIS134GGORANGE12
10FW18WOMENSCOTTONSZARAGHR381BLACK5

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

ABC
1SeasonFW18
2GenderMENS
3Division
4Exclude DivisionCottons
5
6BrandUnitsCC's
7Oasis202
8Gap00
9ZARA00
10H&M00

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1



B7 of Sheet1 must house:

=SUMIFS(total,brand,A7,season,IF(B1="","?*",B1),gender,IF(B2="","?*",B2),division,IF(B3="","?*",B3),division,"<>"&B4)

C7 of Sheet1must house:

=COUNTIFS(brand,A7,season,IF(B1="","?*",B1),gender,IF(B2="","?*",B2),division,IF(B3="","?*",B3),division,"<>"&B4)

Beautiful thank you!
 
Upvote 0

Forum statistics

Threads
1,215,034
Messages
6,122,782
Members
449,095
Latest member
m_smith_solihull

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