Formula: Count of Unique 'Afhaalpunt' for this 'Artikel_Nr'

Roy_Excel_Island_Apps

Board Regular
Joined
Oct 9, 2018
Messages
69
Office Version
  1. 365
Platform
  1. Windows
Hi, can someone help me to find the formula that I can fill out in column C to count all unique Shop_ID's per Article_ID?

ABC
1Shop_IDArticle_IDCount of Unique Shop_ID's for the linked Article_ID
220515789 Result has to be '4'
35543187
420615789
520515789(This is a double one with the first record, so don't count it)
65543187
74443187
85515789
94443187
109515789

<tbody>
</tbody>

Thanks !

Roy
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
In C2 control+shift+enter, not just enter, and copy down:

=SUM(IF(FREQUENCY(IF($B$2:$B$10=$B2,$A$2:$A$10),$A$2:$A$10),1))
 
Upvote 0
Do you have very large rages to calculate?

Yes, Aladin, that's why I changed your formula to: {=SUM(IF(FREQUENCY(IF([Article_ID]=$L2;[Shop_ID]);[Shop_ID]);1))}
This seems to be working but needs a lot of time to calculate and recalculate on sheet change.

Anyway thanks for the great help!

Regards, Roy
 
Upvote 0
Yes, Aladin, that's why I changed your formula to: {=SUM(IF(FREQUENCY(IF([Article_ID]=$L2;[Shop_ID]);[Shop_ID]);1))}
This seems to be working but needs a lot of time to calculate and recalculate on sheet change.

Anyway thanks for the great help!

Regards, Roy

How big is the range of Article_ID? Is $L2 part of it?
 
Upvote 0
The range is like 30.000 records. $L2 is part of the article ID, yes.


Using the earlier layout, we could also have the following: In C2 control+shift+enter, not just enter, and copy down...

=IF(ISNUMBER(MATCH($B2,$B$1:B1,0)),VLOOKUP($B2,$B$1:C1,2,0),SUM(IF(FREQUENCY(IF($B$2:$B$10=$B2,$A$2:$A$10),$A$2:$A$10),1)))

Is this faster?
 
Upvote 0
Using the earlier layout, we could also have the following: In C2 control+shift+enter, not just enter, and copy down...

=IF(ISNUMBER(MATCH($B2,$B$1:B1,0)),VLOOKUP($B2,$B$1:C1,2,0),SUM(IF(FREQUENCY(IF($B$2:$B$10=$B2,$A$2:$A$10),$A$2:$A$10),1)))

Is this faster?

I replaced all ranges by the column ranges and executed the formula but the file crashes. Maybe I should add a procedure it to my VBA coding...
 
Upvote 0
I replaced all ranges by the column ranges and executed the formula but the file crashes. Maybe I should add a procedure it to my VBA coding...

We should avoid whole column references for reasonsof efficiency. Perhaps also avoid distinct countinting of shops for the same article many times. What follows is a suggestion in that direction.



Book1
ABCDEF
1Shop_IDArticle_ID02
2205157891articleunique shop count
355431872157894
420615789431872
520515789
65543187
74443187
85515789
94443187
109515789
11
Sheet1


1. Define bignum in the Name Manager as referring to:

=9.99999999999999E+307

2. Define Shop_ID in the Name Manager as referring to:

=Sheet1!$A$2:INDEX(Sheet1!$A:$A,MATCH(bignum,Sheet1!$A:$A))

3. Define Article_ID in the Name Manager as referring to:

=Sheet1!$B$2:INDEX(Sheet1!$B:$B,MATCH(bignum,Sheet1!$A:$A))

Adjust the sheet name to suit in the foregoing formulas.

4. In C1 enter a 0 (mandatory).

5. In C2 just enter and copy down:

=IF(ISNUMBER(MATCH(B2,$B$1:B1,0)),"",LOOKUP(bignum,$C$1:C1)+1)

6. In E1 just enter:

=LOOKUP(bignum,C:C)

7. In E3 just enter and copy down:

=IF(ROWS($E$3:E3)>$E$1,"",LOOKUP(ROWS($E$3:E3),C:C,B:B))

8. Finally, in F3 control+shift+enter, not just enter, and copy down:

=IF($E3="","",SUM(IF(FREQUENCY(IF(Article_ID=$E3,Shop_ID),Shop_ID),1 )))

I expect this set up to be much faster.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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