Forum Discussion
TomerIwanir
Feb 09, 2025Copper Contributor
Formula assistant
Hi All, Attached the following pic: Im trying to create the yellow cells by formula (I made it manually) the rules: if the column date and the raw date is a match so it should give us col...
- Feb 09, 2025
I recommend that you add a "counter" row as shown in row 2 below so you can accomplish this. Then the formula in I6 can be:
=IF($C6=I$1,$H6,IF(I$2-MATCH($C6,$I$1:$T$1)=1,$H6/4*(-3),IF(AND(I$2-MATCH($C6,$I$1:$T$1)>1,I$2-MATCH($C6,$I$1:$T$1)<5),($H6/4*(-3))/3,0)))
=IF($C6=I$1,$H6,IF(I$2-MATCH($C6,$I$1:$T$1)=1,$H6/4*(-3),IF(AND(I$2-MATCH($C6,$I$1:$T$1)>1,I$2-MATCH($C6,$I$1:$T$1)<5),($H6/4*(-3))/3,0)))
Copy across and down. It can be simplified a little bit to =LET(baseval,MATCH($C6,$I$1:$T$1),IF($C6=I$1,$H6,IF(I$2-baseval=1,$H6/4*(-3),IF(AND(I$2-baseval>1,I$2-baseval<5),($H6/4*(-3))/3,0))))
=LET(baseval,MATCH($C6,$I$1:$T$1),IF($C6=I$1,$H6,IF(I$2-baseval=1,$H6/4*(-3),IF(AND(I$2-baseval>1,I$2-baseval<5),($H6/4*(-3))/3,0))))
Patrick2788
Feb 10, 2025Silver Contributor
It's tempting to draw up a recursive staircasing solution with MUNIT but that function is not very robust and combining the matrices is messy.
This can be done with mostly shaping and wrapping:
=LET(
k, ROWS(dates),
w, k * 2 - 1,
a, amount / -4 * 3,
b, a / SEQUENCE(, 3, -3, 0),
stack, EXPAND(HSTACK(amount, a, b), , w + 1, 0),
return, WRAPROWS(DROP(TOCOL(stack), -k), w, 0),
return
)