counting combinations of 3's

excelNewbie22

Well-known Member
Joined
Aug 4, 2021
Messages
549
Office Version
  1. 365
Platform
  1. Windows
hi, i got help here Excel Questions
regarding counting combinations of 2's,
now i need to do so for 3's, and 4's,
can someone help me modify it?
Excel Formula:
=LET(t,TOCOL(C2:H3),SUM(--(DROP(t,-1)&"-"&DROP(t,1)=C1:G1&"-"&D1:H1)))
and maybe explain it to me in a few words?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi @coulombevin,

Just a heads up, by changing the final calculation of the LET formula shown in your mini-sheet from:
Excel Formula:
SUM(BYROW(uniqueTest,LAMBDA(r,IFERROR(ROWS(FILTER(allPossibilities,allPossibilities=r)),0))))
to:
Excel Formula:
SUM(BYROW(uniqueTest,LAMBDA(r,LAMBDA(t,SUM(IF(t="",0,ROWS(t))))(FILTER(allPossibilities,allPossibilities=r,"")))))
you've inadvertently caused the result to return ROWS(t)^2, because t (FILTER) returns an array object (TYPE 64), and when IF receives an array object in its logical_test argument, both the [value_if_true] and [value_if_false] arguments are resized via broadcasting to fill the same number of rows and/or columns. For example, when FILTER returns 2 rows of matching possibilities, t="" returns {FALSE;FALSE}, which causes IF to return {2;2}. You could replace SUM with the implicit intersection operator (@) to return the first element of the resulting array, but honestly the first version of your formula with IFERROR was just as good. ;)

Another possible variation of the lambda function definition using similar logic could be:
Excel Formula:
=LAMBDA(test_row,array_to_test,number_chosen,
    LET(
        λ, LAMBDA(a,n,
            LET(
                w, COLUMNS(a),
                j, MIN(w,n),
                i, w-j+1,
                k, SEQUENCE(i)+SEQUENCE(,j,0),
                TEXTBEFORE(TEXTAFTER(BYROW(a,LAMBDA(r,TEXTJOIN("-",0,"",INDEX(r,k),""))),"-",SEQUENCE(,i,,j)),"-",j)
            )
        ),
        t, TOCOL(λ(test_row,number_chosen)),
        SUM(BYROW(λ(array_to_test,number_chosen),LAMBDA(r,SUM(N(t=r)))))
    )
)
Cheers!
 
Upvote 0
Hi @djclements ,

That explains why I had everything with a power of 2 ... I tried so much to finaly end up with IFERRORS ...

Thanks for the explanation and for taking the time to develop this new formula,

Vincent
 
Upvote 0

Forum statistics

Threads
1,225,729
Messages
6,186,692
Members
453,369
Latest member
positivemind

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