I have 2 columns; start date and end date and I’d like to create the sequence of months between the two dates.
I can do this using formula and then copying the formula through the whole column
=TEXTJOIN(",",TRUE,SEQUENCE(1,MONTH(B2)-MONTH(A2)+1,MONTH(A2),1))
However, I’d like this to be created as an array. I have tried the following but it doesn’t seem to work:
=BYROW(A2:B4,LAMBDA(a,TEXTJOIN(",",TRUE,SEQUENCE(1,MONTH(CHOOSECOLS(a,2))-MONTH(CHOOSECOLS(a,1))+1,MONTH(CHOOSECOLS(a,1)),1))))
What am I doing wrong here?
>Solution :
Try using the following formula:
=BYROW(MONTH(A2:B4),LAMBDA(α, LET(δ, INDEX(α,1), TEXTJOIN(",",,SEQUENCE(INDEX(α,2)-δ+1,,δ)))))
Edit: Using CHOOSECOLS() is also possible, only that its an array function, you would need to use the implicit intersection operator to make Excel realize that custom LAMBDA() had to be applied per row, while using INDEX() it does not require as it takes the row reference for the cols. Also using @ it needs one extra keying while the INDEX() doesn’t!
=BYROW(MONTH(A2:B4),LAMBDA(α,
LET(δ,@CHOOSECOLS(α,1),TEXTJOIN(",",,
SEQUENCE(@CHOOSECOLS(α,2)-δ+1,,δ)))))


