Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 860
- Office Version
- 365
- Platform
- Windows
AMERGE arrays Merge, same functionality as in Power Querry join/merge scenario called Left Outer. Calls ATEXTJOIN , ARRANGE , APPEND2H
Other functions used on minisheet ARRANGE , APIVOT
Other functions used on minisheet ARRANGE , APIVOT
Excel Formula:
=LAMBDA(l,r,klf,krt,
LET(d,"|",kl,UNIQUE(IF(klf=0,1,klf),1),kr,UNIQUE(IF(krt=0,1,krt),1),
cl,COLUMNS(l),ql,SEQUENCE(,cl),cr,COLUMNS(r),qr,SEQUENCE(,cr),rl,ROWS(l),sl,SEQUENCE(rl),rr,ROWS(r),sr,SEQUENCE(rr),
ckr,COLUMNS(kr),a,INDEX(l,sl,kl),b,INDEX(r,sr,kr),ta,ATEXTJOIN(a,,,d),tb,ATEXTJOIN(b,,,d),
x,XMATCH(ta,tb),ar,ARRANGE(INDEX(r,x,qr),kr),
ml,OR(ISNA(XMATCH(kl,ql))),mr,OR(ISNA(XMATCH(kr,qr))),
IF(OR(ml,mr),"check keys",APPEND2H(l,ar,ckr+1))
)
)
LAMBDA 7.0.xlsx | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | |||
1 | PQ name: Left Outter (Classic lookup in right array) | PQ name: Right Outter (Classic lookup in left array) | |||||||||||||||||||||||
2 | ex. 1 | =AMERGE(A3:C15,E3:H11,{3,2},{2,4}) | =AMERGE(E3:H11,A3:C15,{2,4},{3,2}) | ||||||||||||||||||||||
3 | Units | Color | Product | Code | Product | Price | Color | Units | Color | Product | Code | Price | Code | Product | Price | Color | Units | ||||||||
4 | 48 | Red | Quad | CR-r | Carlota | 26 | Red | 48 | Red | Quad | QD-r | 43 | CR-r | Carlota | 26 | Red | |||||||||
5 | 156 | Blue | Quad | KK-b | Kiki | 13 | Blue | 156 | Blue | Quad | QD-b | 41 | KK-b | Kiki | 13 | Blue | |||||||||
6 | 168 | Red | Quad | QD-r | Quad | 43 | Red | 168 | Red | Quad | QD-r | 43 | QD-r | Quad | 43 | Red | 48 | ||||||||
7 | 132 | Blue | Carlota | SH-r | Sunshine | 19 | Red | 132 | Blue | Carlota | SH-r | Sunshine | 19 | Red | 108 | ||||||||||
8 | 72 | Blue | Carlota | CR-g | Carlota | 24 | Green | 72 | Blue | Carlota | CR-g | Carlota | 24 | Green | |||||||||||
9 | 108 | Red | Sunshine | QD-b | Quad | 41 | Blue | 108 | Red | Sunshine | SH-r | 19 | QD-b | Quad | 41 | Blue | 156 | ||||||||
10 | 128 | Blue | Quad | SH-b | Sunshine | 18 | Blue | 128 | Blue | Quad | QD-b | 41 | SH-b | Sunshine | 18 | Blue | 24 | ||||||||
11 | 96 | Red | Gigi | KK-r | Kiki | 20 | Red | 96 | Red | Gigi | KK-r | Kiki | 20 | Red | |||||||||||
12 | 60 | Red | Sunshine | 60 | Red | Sunshine | SH-r | 19 | |||||||||||||||||
13 | 24 | Blue | Sunshine | 24 | Blue | Sunshine | SH-b | 18 | Obs: | If there are duplicates of keys in | |||||||||||||||
14 | 120 | Blue | Carlota | 120 | Blue | Carlota | left array,only first occurrence is shown | ||||||||||||||||||
15 | 24 | Blue | Quad | 24 | Blue | Quad | QD-b | 41 | |||||||||||||||||
16 | |||||||||||||||||||||||||
17 | ex. 2 | error debug. | |||||||||||||||||||||||
18 | Invoice | Product | Sales | Invoice | Discount | =AMERGE(A4:C15,E4:H11,{4,2},{2,4}) | |||||||||||||||||||
19 | 4588 | Carlota | 130 | 4588 | 0.065 | check keys | |||||||||||||||||||
20 | 4588 | Quad | 559 | 4589 | 0.0375 | ||||||||||||||||||||
21 | 4588 | Sunshine | 114 | 4590 | 0.12 | (key left columns out of range) | |||||||||||||||||||
22 | 4589 | Quad | 559 | ||||||||||||||||||||||
23 | 4589 | Sunshine | 209 | =ARRANGE(J3#,{3,4,2,5}) | other functions used on minisheet | ||||||||||||||||||||
24 | 4590 | Carlota | 2869 | Product | Code | Color | Price | Units | ARRANGE | ||||||||||||||||
25 | Quad | QD-r | Red | 43 | 48 | APIVOT | |||||||||||||||||||
26 | =AMERGE(A18:C24,E18:F21,,) | Quad | QD-b | Blue | 41 | 156 | |||||||||||||||||||
27 | Invoice | Product | Sales | Discount | Total | Quad | QD-r | Red | 43 | 168 | |||||||||||||||
28 | 4588 | Carlota | 130 | 6.50% | 121.55 | Carlota | Blue | 132 | |||||||||||||||||
29 | 4588 | Quad | 559 | 6.50% | 522.665 | Carlota | Blue | 72 | |||||||||||||||||
30 | 4588 | Sunshine | 114 | 6.50% | 106.59 | Sunshine | SH-r | Red | 19 | 108 | |||||||||||||||
31 | 4589 | Quad | 559 | 3.75% | 538.0375 | Quad | QD-b | Blue | 41 | 128 | |||||||||||||||
32 | 4589 | Sunshine | 209 | 3.75% | 201.1625 | Gigi | Red | 96 | |||||||||||||||||
33 | 4590 | Carlota | 2869 | 12.00% | 2524.72 | Sunshine | SH-r | Red | 19 | 60 | |||||||||||||||
34 | Sunshine | SH-b | Blue | 18 | 24 | ||||||||||||||||||||
35 | =APIVOT(A28:E33,1,2,5,) | Carlota | Blue | 120 | |||||||||||||||||||||
36 | (1\2) 5 vf=0 | Carlota | Quad | Sunshine | Grand Total | Quad | QD-b | Blue | 41 | 24 | |||||||||||||||
37 | 4588 | 121.55 | 522.665 | 106.59 | 750.805 | ||||||||||||||||||||
38 | 4589 | 0 | 538.0375 | 201.1625 | 739.2 | ||||||||||||||||||||
39 | 4590 | 2524.72 | 0 | 0 | 2524.72 | ||||||||||||||||||||
40 | Grand Total | 2646.27 | 1060.7025 | 307.7525 | 4014.725 | ||||||||||||||||||||
41 | |||||||||||||||||||||||||
AMERGE post |
Cell Formulas | ||
---|---|---|
Range | Formula | |
J2,P2,A35,A26,J23,J18 | J2 | =FORMULATEXT(J3) |
J3:N15 | J3 | =AMERGE(A3:C15,E3:H11,{3,2},{2,4}) |
P3:T11 | P3 | =AMERGE(E3:H11,A3:C15,{2,4},{3,2}) |
J19 | J19 | =AMERGE(A4:C15,E4:H11,{4,2},{2,4}) |
J24:N36 | J24 | =ARRANGE(J3#,{3,4,2,5}) |
A27:D33 | A27 | =AMERGE(A18:C24,E18:F21,,) |
E28:E33 | E28 | =C28:C33*(1-D28:D33) |
A36:E40 | A36 | =APIVOT(A28:E33,1,2,5,) |
Dynamic array formulas. |
Upvote
0