Count unique values across two columns

Wishmaster89

Board Regular
Joined
Jan 10, 2022
Messages
77
Office Version
  1. 2021
  2. 2019
  3. 2016
Platform
  1. Windows
  2. MacOS
Hi All

I am trying to count the number of ID's that start in 2017. I know you can do sumproduct with count if , but i couldnt't get it working with countifs.

Sample data below.

QAR withdrawal comparison.xlsx
AB
1IDStart_Year
212017
322017
432017
542017
652018
762017
872017
912018
1092017
11102017
1252018
13112017
14122017
15132017
1692018
Sheet1
 
Should be able to multiply as many column conditions as you want.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi, i have a related question to my original post.

Is it possible to use the Count(Unique(Filter combination to count unique ID's except where the course is different?
E.g. ID 1 and 4 will be counted twice as they have 2 different courses


Book1
ABCD
1IDCourseyearstatus
21History17/181
32Sports17/182
43IT17/181
54English17/183
65History17/186
71IT17/182
82Sports17/183
94Math17/181
Sheet1
 
Upvote 0
Ignore above, this is a better example.

So here i usually use Count(unique(filter which works great. However on the bottom 3 rows, the start year (L), ID(A) and status (C) are the same but the standard_description is different so i want this ID to be counted twice instead of only once which Count(unique(filter will give. The reason i want to keep the filter in is so i can check other criteria such as status(B), months(L) ect. Unless theres another way to do it?

Book7
ABCDEFGHIJKL
1IDCompletion_StatusLearning_OutcomeStandard_DescriptionLearning_Start_DateLearning_Planned_End_DateLearning_Actual_End_DateWithdrawal daysMonthsMin startMin start yearLast row of id/course
2119Insurance Practitioner10/04/2018 00:0009/10/2019 00:0010/04/201817/18
3133Business Administrator08/01/2018 00:0007/04/2019 00:0007/02/2018 00:00300-608/01/201817/18
4133Insurance Practitioner10/04/2018 00:0009/10/2019 00:0029/08/2018 00:001410-610/04/201817/181
5133Business Administrator08/01/2018 00:0007/04/2019 00:0007/02/2018 00:00300-608/01/201817/181
Sheet1
 
Upvote 0
See if this is what you mean. (Check Table name)

Wishmaster89.xlsm
ADIKMN
1IDStandard_DescriptionMonthsMin start year
21Insurance Practitioner17/182
31Business Administrator0-617/18
41Insurance Practitioner0-617/18
51Business Administrator0-617/18
Sheet1
Cell Formulas
RangeFormula
N2N2=IFNA(ROWS(UNIQUE(FILTER(Table1[ID]&"|"&Table1[Standard_Description],(Table1[Min start year]="17/18")*(Table1[Months]="0-6"),NA()))),0)
 
Upvote 0
See if this is what you mean. (Check Table name)

Wishmaster89.xlsm
ADIKMN
1IDStandard_DescriptionMonthsMin start year
21Insurance Practitioner17/182
31Business Administrator0-617/18
41Insurance Practitioner0-617/18
51Business Administrator0-617/18
Sheet1
Cell Formulas
RangeFormula
N2N2=IFNA(ROWS(UNIQUE(FILTER(Table1[ID]&"|"&Table1[Standard_Description],(Table1[Min start year]="17/18")*(Table1[Months]="0-6"),NA()))),0)
Yep that works thank you.
 
Upvote 0
See if this is what you mean. (Check Table name)

Wishmaster89.xlsm
ADIKMN
1IDStandard_DescriptionMonthsMin start year
21Insurance Practitioner17/182
31Business Administrator0-617/18
41Insurance Practitioner0-617/18
51Business Administrator0-617/18
Sheet1
Cell Formulas
RangeFormula
N2N2=IFNA(ROWS(UNIQUE(FILTER(Table1[ID]&"|"&Table1[Standard_Description],(Table1[Min start year]="17/18")*(Table1[Months]="0-6"),NA()))),0)
I've been playing round with the formula and have the following question. I know & concatenates two fields but what does | do please?
 
Upvote 0
Yep that works thank you.
Good news. Thanks for the confirmation. (y)

I know & concatenates two fields but what does | do please?
It is a safety mechanism to ensure that you are actually comparing IDs & Descriptions.
With the samples below, using the "|" you get
"1c|hop"
"1|chop"
Rightly, these produce two unique ID/Description combinations.

If we did not use the "|" to delimit the columns then the concatenation would give only 1 unique combination. :)
"1chop"
"1chop"

Wishmaster89.xlsm
AB
1IDDescription
21chop
31chop
Sheet3
 
Upvote 0
Good news. Thanks for the confirmation. (y)


It is a safety mechanism to ensure that you are actually comparing IDs & Descriptions.
With the samples below, using the "|" you get
"1c|hop"
"1|chop"
Rightly, these produce two unique ID/Description combinations.

If we did not use the "|" to delimit the columns then the concatenation would give only 1 unique combination. :)
"1chop"
"1chop"

Wishmaster89.xlsm
AB
1IDDescription
21chop
31chop
Sheet3
Ah yes of course thanks. Its made me think about how i do index match with more than 1 look up value, usually i just use & and it does give the correct answer. But 'm now thinking i should add in the |.
 
Upvote 0
But 'm now thinking i should add in the |.
Sometimes it would not be needed. For example if you know your data well and say the first column is names and the second column is dates then the sort of issue I mentioned could not arise.
However, it should never hurt to include such a delimiter - which can be anything so long as it is not going to already occur naturally within any of the data.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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