JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
I'm trying to create a LAMBDA function as follows:
Inputs
column of numbers: "arr"
fixed array: "flags" = {6, 9, 50, 200}
fixed integer: "lag" = 2
Process
Create 4 columns of:
Rolling sum of 6 values offset by 2 of "arr" (1)
Rolling sum of 9 values offset by 2 of "arr" (2)
Moving average of 50 values of (1) (3)
Moving average of 200 values of (2) (4)
Output
Single column of values:
So far I have:
If my values are in J2:J510 and I enter the formula into L2, it correctly returns 0 in L2:L9 but REF#! in L10 onwards
L9 should be SUM(J2:J7)
L10: SUM(J3:J8)
L11: SUM(J4:J9)
etc
It should then be easy to expand to the second column, similar values but a flag of 9 not 6 by looping over INDEX(flags,x)
I intuit for columns 3 and 4, something like If(Index(flags,x))<3,"SUM","AVERAGE" and adapt the SUM function to AVERAGE the moving range instead.
Can anyone help with this first part?
TIA, Jack
I'm trying to create a LAMBDA function as follows:
Inputs
column of numbers: "arr"
fixed array: "flags" = {6, 9, 50, 200}
fixed integer: "lag" = 2
Process
Create 4 columns of:
Rolling sum of 6 values offset by 2 of "arr" (1)
Rolling sum of 9 values offset by 2 of "arr" (2)
Moving average of 50 values of (1) (3)
Moving average of 200 values of (2) (4)
Output
Single column of values:
Excel Formula:
=SIGN(SUM([1:4])/4)
So far I have:
Excel Formula:
=LET(arr,$J2#,f,INDEX(flags,1),l,f+lag-1,m,SEQUENCE(ROWS(arr)),IF(m>l,SUM(OFFSET($J$2,m-l,,f)),0))
If my values are in J2:J510 and I enter the formula into L2, it correctly returns 0 in L2:L9 but REF#! in L10 onwards
L9 should be SUM(J2:J7)
L10: SUM(J3:J8)
L11: SUM(J4:J9)
etc
It should then be easy to expand to the second column, similar values but a flag of 9 not 6 by looping over INDEX(flags,x)
I intuit for columns 3 and 4, something like If(Index(flags,x))<3,"SUM","AVERAGE" and adapt the SUM function to AVERAGE the moving range instead.
Can anyone help with this first part?
TIA, Jack