T_IFS

=T_IFS(f,w,p)

f
"find" array , (vertical vectors)
w
"within" array, (horizontal vectors (transposed into horizontal by formula))
p
pattern array, always ignored, carries the pattern array result of 0's and 1's

tool-recursive lambda that creates pattern array used in MMULT formula construction as only alternative to SUMIFS COUNTIFS

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
832
Office Version
  1. 365
Platform
  1. Windows
T_IFS !! recursive !! tool-recursive lambda that creates pattern array used in MMULT formula construction as only alternative to SUMIFS COUNTIFS…formulas that are limited to range arguments.
One of Geert's comments on YT , inspired me in trying to address the drawbacks of SUMIFS, COUNTIFS...*IFS functions that can handle only range arguments and not array arguments. Thank him for that!!!
This tool is the piston of the motor who is able to overcame this drawbacks, and even more, can leed us to be able to write lambdas that can do grouping or "group by" as in PT or PQ.
What the formula does, is very simple, is comparing ("=" operator) vertical arrays with horizontal arrays and multiplies the result. (v1=h1)*(v2=h2)*.....*(vn=hn), recursively one (vk=hk) at a time.
The outcome will be an array of rows(v) x columns (h) full of 0 and 1 , useful in MMULT constructions for counting or summing.
Excel Formula:
=LAMBDA(f,w,p,
    LET(k,IF(COUNTA(p)=1,1,p),cf,COLUMNS(f),sf,SEQUENCE(ROWS(f)),cw,COLUMNS(w),sw,SEQUENCE(ROWS(w)),
       n,IF(cf=cw,cf,"x"),v,INDEX(f,,n),h,INDEX(w,,n),
       IF(n="x","check arrays",IF(n=1,k*(v=TRANSPOSE(h)),k*T_IFS(INDEX(f,sf,SEQUENCE(,n-1)),INDEX(w,sw,SEQUENCE(,n-1)),v=TRANSPOSE(h))))
    )
)
LAMBDA 7.0.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1tool-recursive lambda that creates pattern array used in MMULT formula construction as only alternative to SUMIFS COUNTIFS…formulas that are limited to range arguments
2find and within array should have same width(same clm nr)MMULT construnction,COUNTIFS alternative
3find or criteria array=MMULT(J5#,SEQUENCE(ROWS(A5:D19))^0)
4"within" array=ACOMBINE(A5:C19,)=T_IFS(F5#,A5:C19,)check:=COUNTIFS(A5:A19,F5:F16,B5:B19,G5:G16,C5:C19,H5:H16)
5Bcx3Aax01000000000000011
6Aax1Aay00000010000001133
7Bbx2Abx00000000010000011
8Acy6Aby00000000000000000
9Bby4Acx00000000000000000
10Bbx8Acy00010001000100033
11Aay6Bax00000000001000011
12Acy4Bay00000000000000000
13Bby5Bbx00100100000010033
14Abx3Bby00001000100000022
15Bax9Bcx10000000000000011
16Acy3Bcy00000000000000000
17Bbx3
18Aay8MMULT construnction,SUMIFS alternative
19Aay7check- this is the sequence of calculations done by the formula=MMULT(J5#,D5:D19)
20=(G5:G16=TRANSPOSE(B5:B19))*(H5:H16=TRANSPOSE(C5:C19))*(F5:F16=TRANSPOSE(A5:A19))check:=SUMIFS(D5:D19,A5:A19,F5:F16,B5:B19,G5:G16,C5:C19,H5:H16)
2101000000000000011
220000001000000112121
23other functions on minisheet00000000010000033
24ACOMBINE00000000000000000
2500000000000000000
260001000100010001313
2700000000001000099
2800000000000000000
290010010000001001313
3000001000100000099
3110000000000000033
3200000000000000000
33
34=T_IFS(F35:H36,A5:C19,)
35Acy000100010001000
36Bax000000000010000
37
T_IFS post
Cell Formulas
RangeFormula
Z3,Z19Z3=FORMULATEXT(Z5)
F4,J4,J34,AB20,AB4F4=FORMULATEXT(F5)
F5:H16F5=ACOMBINE(A5:C19,)
J5:X16J5=T_IFS(F5#,A5:C19,)
Z5:Z16Z5=MMULT(J5#,SEQUENCE(ROWS(A5:D19))^0)
AB5:AB16AB5=COUNTIFS(A5:A19,F5:F16,B5:B19,G5:G16,C5:C19,H5:H16)
G20G20=FORMULATEXT(J21)
J21:X32J21=(G5:G16=TRANSPOSE(B5:B19))*(H5:H16=TRANSPOSE(C5:C19))*(F5:F16=TRANSPOSE(A5:A19))
Z21:Z32Z21=MMULT(J5#,D5:D19)
AB21:AB32AB21=SUMIFS(D5:D19,A5:A19,F5:F16,B5:B19,G5:G16,C5:C19,H5:H16)
J35:X36J35=T_IFS(F35:H36,A5:C19,)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,214,986
Messages
6,122,611
Members
449,090
Latest member
vivek chauhan

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