Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 860
- Office Version
- 365
- Platform
- Windows
AAGGREGATE !! recursive !! array aggregate by each row of an array, various functions (0-MIN,1-MAX, 2-AND, 3-OR, 4-XOR, 5-SUM, 6-PRODUCT, 7-AVERAGE, 8-COUNT, 9-COUNTA, 10-MEDIAN, 11-SMALL, 12-LARGE, calls APPEND2V
Excel Formula:
=LAMBDA(a,fn,k,
LET(n,ROWS(a),c,COLUMNS(a),y,INDEX(a,n,),x,SWITCH(fn,0,MIN(y),1,MAX(y),2,AND(y),3,OR(y),4,XOR(y),
5,SUM(y),6,PRODUCT(y),7,AVERAGE(y),8,COUNT(y),9,SUM(--(y<>"")),10,MEDIAN(y),11,SMALL(y,k),12,LARGE(y,k),"check data"),
IF(n=1,APPEND2V(x,a,2),APPEND2V(AAGGREGATE(INDEX(a,SEQUENCE(n-1),SEQUENCE(,c)),fn,k),x,))
)
)
LAMBDA 6.0.xlsx | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | |||
1 | fn | f-ction | fn | 0 | 1 | 5 | 6 | 7 | 10 | 11 | 12 | 2 | kls | ||||||||||
2 | 0 | MIN | 1 | 2 | 3 | 4 | 5 | 1 | 5 | 15 | 120 | 3 | 3 | 2 | 4 | ||||||||
3 | 1 | MAX | 6 | 7 | 8 | 9 | 10 | 6 | 10 | 40 | 30240 | 8 | 8 | 7 | 9 | ||||||||
4 | 2 | AND | 11 | 12 | 13 | 14 | 15 | 11 | 15 | 65 | 360360 | 13 | 13 | 12 | 14 | ||||||||
5 | 3 | OR | 16 | 17 | 18 | 19 | 20 | 16 | 20 | 90 | 1860480 | 18 | 18 | 17 | 19 | ||||||||
6 | 4 | XOR | 21 | 22 | 23 | 24 | 25 | 21 | 25 | 115 | 6375600 | 23 | 23 | 22 | 24 | ||||||||
7 | 5 | SUM | 26 | 27 | 28 | 29 | 30 | 26 | 30 | 140 | 17100720 | 28 | 28 | 27 | 29 | ||||||||
8 | 6 | PRODUCT | 31 | 32 | 33 | 34 | 35 | 31 | 35 | 165 | 38955840 | 33 | 33 | 32 | 34 | ||||||||
9 | 7 | AVERAGE | 36 | 37 | 38 | 39 | 40 | 36 | 40 | 190 | 78960960 | 38 | 38 | 37 | 39 | ||||||||
10 | 8 | COUNT | 41 | 42 | 43 | 44 | 45 | 41 | 45 | 215 | 146611080 | 43 | 43 | 42 | 44 | ||||||||
11 | 9 | COUNTA | 46 | 47 | 48 | 49 | 50 | 46 | 50 | 240 | 254251200 | 48 | 48 | 47 | 49 | ||||||||
12 | 10 | MEDIAN | 51 | 52 | 53 | 54 | 55 | 51 | 55 | 265 | 417451320 | 53 | 53 | 52 | 54 | ||||||||
13 | 11 | SMALL | 56 | 57 | 58 | 59 | 60 | 56 | 60 | 290 | 655381440 | 58 | 58 | 57 | 59 | ||||||||
14 | 12 | LARGE | 61 | 62 | 63 | 64 | 65 | 61 | 65 | 315 | 991186560 | 63 | 63 | 62 | 64 | ||||||||
15 | 66 | 67 | 68 | 69 | 70 | 66 | 70 | 340 | 1452361680 | 68 | 68 | 67 | 69 | ||||||||||
16 | 71 | 72 | 73 | 74 | 75 | 71 | 75 | 365 | 2071126800 | 73 | 73 | 72 | 74 | ||||||||||
17 | 76 | 77 | 78 | 79 | 80 | 76 | 80 | 390 | 2884801920 | 78 | 78 | 77 | 79 | ||||||||||
18 | 81 | 82 | 83 | 84 | 85 | 81 | 85 | 415 | 3936182040 | 83 | 83 | 82 | 84 | ||||||||||
19 | 86 | 87 | 88 | 89 | 90 | 86 | 90 | 440 | 5273912160 | 88 | 88 | 87 | 89 | ||||||||||
20 | 91 | 92 | 93 | 94 | 95 | 91 | 95 | 465 | 6952862280 | 93 | 93 | 92 | 94 | ||||||||||
21 | 96 | 97 | 98 | 99 | 100 | 96 | 100 | 490 | 9034502400 | 98 | 98 | 97 | 99 | ||||||||||
22 | |||||||||||||||||||||||
23 | fn | 8 | 9 | 2 | 3 | 4 | |||||||||||||||||
24 | a | -1 | TRUE | b | 1 | 4 | TRUE | TRUE | FALSE | TRUE | TRUE | ||||||||||||
25 | 0 | b | d | 1 | 3 | FALSE | TRUE | TRUE | TRUE | FALSE | |||||||||||||
26 | 4 | 3 | 2 | 5 | 4 | 4 | FALSE | FALSE | FALSE | FALSE | FALSE | ||||||||||||
27 | |||||||||||||||||||||||
AAGGREGATE post |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D2:H21 | D2 | =SEQUENCE(20,5) |
K2:P21 | K2 | =AAGGREGATE($D$2#,K1,) |
Q2:R21 | Q2 | =AAGGREGATE($D$2#,Q1,$S$1) |
K24:K26 | K24 | =AAGGREGATE($D$24:$H$26,K23,) |
L24:L26 | L24 | =AAGGREGATE($D$24:$H$26,9,) |
M24:O26 | M24 | =AAGGREGATE($Q$24:$R$26,M23,) |
Dynamic array formulas. |
Upvote
0