Counting Unique if theres a value in another field

creative999

Board Regular
Joined
Jul 7, 2021
Messages
114
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
  2. MacOS
I want to count how many unique Sale IDs there are:

a. if there is a value in the Rev Share column.
and separatly,
b. the Sale ID has NO Rev Share

So in the attached example:
a. = 3
b. = 2

Any suggestions:

Book2
AB
1REV SHARESALE ID
2ABCa9e
3a9e
4ABCa9e
5XYZa9e
6a9e
764M
864M
964M
1064M
11VXq
12DEFVXq
13VXq
14DEFVXq
15VXq
16ABC7Qe
17ABC7Qe
187Qe
197Qe
20DEF7Qe
217Qe
22Xp2
23Xp2
24Xp2
25Xp2
26Xp2
Sheet1
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try

Pasta1
ABCDE
1REV SHARESALE IDQuestion aQuestion b
2ABCa9e32
3a9e
4ABCa9e
5XYZa9e
6a9e
764M
864M
964M
1064M
11VXq
12DEFVXq
13VXq
14DEFVXq
15VXq
16ABC7Qe
17ABC7Qe
187Qe
197Qe
20DEF7Qe
217Qe
22Xp2
23Xp2
24Xp2
25Xp2
26Xp2
Plan3
Cell Formulas
RangeFormula
D2D2=SUM(IF(FREQUENCY(IF(A2:A26<>"",MATCH(B2:B26,B2:B26,0)),ROW(B2:B26)-ROW(B2)+1),1))
E2E2=SUM(IF(FREQUENCY(IF(COUNTIFS(A2:A26,"<>",B2:B26,B2:B26)=0,MATCH(B2:B26,B2:B26,0)),ROW(B2:B26)-ROW(B2)+1),1))
Press CTRL+SHIFT+ENTER to enter array formulas.


M.
 
Upvote 0
Question b - a simpler formula

Pasta1
DE
1Question aQuestion b
232
Plan3
Cell Formulas
RangeFormula
D2D2=SUM(IF(FREQUENCY(IF(A2:A26<>"",MATCH(B2:B26,B2:B26,0)),ROW(B2:B26)-ROW(B2)+1),1))
E2E2=SUM(IF(FREQUENCY(MATCH(B2:B26,B2:B26,0),ROW(B2:B26)-ROW(B2)+1),1))-D2
Press CTRL+SHIFT+ENTER to enter array formulas.


M.
 
Upvote 0
With Excel 365:

Book1
ABCDE
1REV SHARESALE IDQuestion AQuestion B
2ABCa9e35
3a9e
4ABCa9e
5XYZa9e
6a9e
764M
864M
964M
1064M
11VXq
12DEFVXq
13VXq
14DEFVXq
15VXq
16ABC7Qe
17ABC7Qe
187Qe
197Qe
20DEF7Qe
217Qe
22Xp2
23Xp2
24Xp2
25Xp2
26Xp2
Sheet14
Cell Formulas
RangeFormula
D2D2=ROWS(UNIQUE(FILTER(B2:B26,(A2:A26<>""))))
E2E2=ROWS(UNIQUE(FILTER(B2:B26,(A2:A26=""))))


For question B, there are 5 unique Sale IDs with a blank Rev Share. Did you mean excluding ones already found, like Marcelo's formula? If so, just subtract D2.
 
Upvote 0
All worked a treat.... now to toss a coin a choose one :)
Thank you so much all
 
Upvote 0
Seems, i also need to check another column for any value, for example:

a. if there is a value in the Rev Share column and there is a value in Col C
 
Upvote 0
A data sample along with expected results would be helpful

M.
The new formula / count here should = 2 (those in red)

Based on the earlier requirement to count unique SALE ID where there is a REV SHARE and INCLUSIVE value.

Book2
ABC
1REV SHARESALE IDINCLUSIVE
2ABCa9eYES
3a9eYES
4ABCa9e
5XYZa9e
6a9eYES
764M
864MYES
964M
1064M
11VXq
12DEFVXq
13VXqYES
14DEFVXq
15VXq
16ABC7QeYES
17ABC7Qe
187Qe
197Qe
20DEF7Qe
217QeYES
22Xp2
23Xp2
24Xp2YES
25Xp2
26Xp2
Sheet1
 
Upvote 0
The Excel 365 way:

Book1
ABCD
1REV SHARESALE IDINCLUSIVEQuestion C
2ABCa9eYES2
3a9eYES
4ABCa9e
5XYZa9e
6a9eYES
764M
864MYES
964M
1064M
11VXq
12DEFVXq
13VXqYES
14DEFVXq
15VXq
16ABC7QeYES
17ABC7Qe
187Qe
197Qe
20DEF7Qe
217QeYES
22Xp2
23Xp2
24Xp2YES
25Xp2
26Xp2
Sheet14
Cell Formulas
RangeFormula
D2D2=ROWS(UNIQUE(FILTER(B2:B26,(A2:A26<>"")*(C2:C26="YES"))))


I was also thinking about the versions A and B from the earlier post. Subtracting D2 from the E2 formula really only works if the two lists overlap. If there's some non-overlapping values, it may not give the expected results.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
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