MAP / LAMBDA Functions to get multiple array elements

MrRajKumar

Active Member
Joined
Jan 29, 2008
Messages
280
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have the following data.

A2:C12

A01K 03L 01
1-Jan-24​
B09K 01L 00
1-Jan-24​
C12K 01L 00
1-Jan-24​
D00K 00L 01
1-Jan-24​
A09K 00L 09
1-Jan-24​
A10K 00L 01
1-Jan-24​
A00K 30L 01
1-Jan-24​
B02K 02L 02
1-Jan-24​
C10K 10L 10
1-Jan-24​
D11K 11L 10
1-Jan-24​
D10K 00L 10
1-Jan-24

E2:F4

A
1-Jan-24​
A
2-Jan-24​
B
4-Jan-24​

H2,

=SORT(UNIQUE(A2:A12))

L2: 1/1/2024
L3: 1/31/2024

L2:L3 is a month period.

In I2 I would like to get based on the following conditions.

1) If the dates in column F are in the month period (L2:L3) and take those dates for the values in H2:H5
2) Then, if these dates are in column C, then FILTER column B values for the values H2:H5
3) Then, SUM their values with help of MID function.

I tried the following, but doesn't work.

=SUM(MID(MAP(H2#,LAMBDA(x,FILTER(F2:F4,(E2:E4=x)*(F2:F4>=L2)*(F2:F4<=L3))),LAMBDA(x,y,FILTER(B2:B12,(A2:A12=x)*ISNUMBER(MATCH(C2:C12,y,0))))),{1,5,9},2)+0)
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I get this to work for individual values in H2:H5

=SUM(MID(FILTER(B$2:B$12,(A$2:A$12=H2)*ISNUMBER(MATCH(C$2:C$12,FILTER(F$2:F$4,(E$2:E$4=H2)*(F$2:F$4>=L$2)*(F$2:F$4<=L$3)),0))),{1,5,9},2)+0)

But, the problem is; the range in column H is in spill. So how can I modify this include the spill range in H?
 
Upvote 0
One idea:
Book1
ABCDEFGHIJKL
1
2A01K 03L 011/1/2024A1/1/2024A651/1/2024
3B09K 01L 001/1/2024A1/2/2024B6
4C12K 01L 001/1/2024B1/4/2024C63
5D00K 00L 011/1/2024C1/1/2024D
6A09K 00L 091/1/2024
7A10K 00L 011/1/2024
8A00K 30L 011/1/2024
9B02K 02L 021/4/2024
10C10K 10L 101/1/2024
11D11K 11L 101/1/2024
12C10K 00L 101/1/2024
Sheet1
Cell Formulas
RangeFormula
H2:I5H2=LET(codes,SORT(UNIQUE(A2:A12)),res,IFERROR(BYROW(codes,LAMBDA(r,SUM(MID(FILTER(B2:B12, ISNUMBER(MATCH(C2:C12,FILTER(F2:F5,(E2:E5=r)*(EOMONTH(+F2:F5,0)=EOMONTH(L2,0)),""),0))*(A2:A12=r),""),{1,5,9},2)+0))),""),HSTACK(codes,res))
Dynamic array formulas.
 
Upvote 0
Solution
I get this to work for individual values in H2:H5

=SUM(MID(FILTER(B$2:B$12,(A$2:A$12=H2)*ISNUMBER(MATCH(C$2:C$12,FILTER(F$2:F$4,(E$2:E$4=H2)*(F$2:F$4>=L$2)*(F$2:F$4<=L$3)),0))),{1,5,9},2)+0)

But, the problem is; the range in column H is in spill. So how can I modify this include the spill range in H?

It seems to me that you were almost there...

Excel Formula:
=MAP(H2#,LAMBDA(x,SUM(MID(FILTER(B$2:B$12,(A$2:A$12=x)*ISNUMBER(MATCH(C$2:C$12,FILTER(F$2:F$4,(E$2:E$4=x)*(F$2:F$4>=L$2)*(F$2:F$4<=L$3)),0))),{1,5,9},2)+0)))

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,201
Messages
6,123,621
Members
449,109
Latest member
Sebas8956

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