Formula : Count Rows in a list that have a fixed number of unique dependencies in another column

RobP

Well-known Member
Joined
May 8, 2008
Messages
859
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am trying to find a formula that will count the number of Projects in a Column which has (x) Unique Product codes in another column.

So looking for a formula to go into L14, N14, and P14.

You can see in L19 (I was playing) my logic took me down a path of counting the number of each project, then I would probably discard rows that were LESS THAN the number I was looking for (so discard rows in M that contained 1 or 2 if I was looking for projects that had "3" unique Prod Codes, for answer in N14). Then somehow correlate that to the product codes in col(I) that I would then need to count.

I'm likely over complicating it.. and sending myself down a wrong path .. there's probably a SUMIF that would fix it for me.

Any ideas on how to solve please ?

thanks
Rob

Design Data Master.xlsx
HIJKLMNOPQR
12
13Count Projects with (x) NumberProj with 2Proj with 3Proj with 4
14of Product Codes (x = 1 to 10)Ans :2Ans:3Ans:0
15(prj 2,5)(prj 4,7,8)<<< added for problem clarity only
16ProjectProd Code
17Project1AA
18Project2AA
19Project2ABProject11
20Project3ACProject22
21Project4AAProject31
22Project4ABProject44
23Project4ABProject52
24Project4ACProject61
25Project5AJProject73
26Project5ABProject83
27Project6BV
28Project7BA
29Project7AB
30Project7AC
31Project8CD
32Project8DS
33Project8AB
Powerpoint
Cell Formulas
RangeFormula
L19:M26L19=LET(prj,UNIQUE(H17:H33),c,SCAN(0,prj,LAMBDA(a,v,COUNTIFS(H17:H33,v))),list,HSTACK(prj,c),list)
Dynamic array formulas.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
How about
Excel Formula:
=LET(g,GROUPBY(H17:H33,I17:I33,COUNTA,,0),ROWS(FILTER(g,TAKE(g,,-1)=2)))
Although I don't see why you are counting Project 4 with 3 codes.
 
Upvote 0
Hi Fluff,

sorry, I forgot to add the only caveat that I knew I should have .... my current version on O365 doesn't have the luxury of @Groupby, or @Pivotby for some reason. I think its down to the version that the company has loaded up (they don't tend to upgrade always). So I'm missing playing with that functionality ... sadly.

But I've no doubt of course what you provided will do the job. FYI, Project 4 counts as a 3 as it has 3 Unique Project codes.

Thanks
Rob
 
Upvote 0
Ok, how about
Excel Formula:
=LET(prj,UNIQUE(H17:H33),c,MAP(prj,LAMBDA(v,ROWS(UNIQUE(FILTER(I17:I33,H17:H33=v))))),SUM(--(c=2)))
 
Upvote 0
Solution
Thanks again Fluff.

If I put the formula into L14, indeed I get the answer = 2. However, if I put the formula into N14, (I changed the c=2 to c=3 as that was the only immediate obvious link to the number of product codes associated with each project), I get the answer = 0 when it should Answer "3" projects (have 3 unique product codes associated with them)

I'm going to have to take a little time to decipher your formula in order to understand a little more about your approach ...

Cheers
Rob
 
Upvote 0
Fluff,

I'm sorry, taking more time on my side, I realised user error :-) I had moved my arrays slightly and didn't correct your formula..

Thats absolutely awesome - thanks a lot.. and never in doubt ;-)

Cheers
Rob
 
Upvote 0

Forum statistics

Threads
1,226,527
Messages
6,191,571
Members
453,665
Latest member
WaterWorks

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