I'm running in this problem where MAKEARRAY doesn't provide the correct result when using it with a varible as input.
I'm try to build kind of a Gantt chart. I have a list of weeks, for every week I find the proper activities belonging to it. The issue is that I need to properly align activities with the weeks before.
Normal result:
Wanted result:
The list of activties are sorted by date, thus i just have to match the first in the column and add extra row to get to the desired line.
I'm using this formula:
=LET(
dataAll; PromoTbl[[SO_inizio]:[SO_ fine]];
daySel; I$5;
cliente; DASHBOARD!$B$2;
filtroCliente; (PromoTbl[[L6]:[L6]]=cliente);
filterWk; ((BYROW(PromoTbl[[SO_ fine]:[SO_ fine]];LAMBDA(row;MIN(daySel+7;row)))-BYROW(PromoTbl[[SO_inizio]:[SO_inizio]];LAMBDA(row;MAX(daySel;row)))+1)>=1);
filterWkBef; ((BYROW(PromoTbl[[SO_ fine]:[SO_ fine]];LAMBDA(row;MIN(daySel-1;row)))-BYROW(PromoTbl[[SO_inizio]:[SO_inizio]];LAMBDA(row;MAX(daySel-7;row)))+1)>=1);
dataWk; SORT(FILTER(dataAll;filtroCliente*filterWk;"NA"));
dataWkBef; SORT(FILTER(dataAll;filtroCliente*filterWkBef;"NA"));
listWk; BYROW(dataWk;LAMBDA(row;IFERROR(TEXT(CHOOSECOLS(row;1);"gg-mmm-aa") & "|" & TEXT(CHOOSECOLS(row;2);"gg-mmm-aa");"")));
listWkBef; BYROW(dataWkBef;LAMBDA(row;IFERROR(TEXT(CHOOSECOLS(row;1);"gg-mmm-aa") & "|" & TEXT(CHOOSECOLS(row;2);"gg-mmm-aa");"")));
firstRow; TAKE(listWk;1);
idx; VALUE(IFNA(MATCH(firstRow;listWkBef;0);1));
spaces; MAKEARRAY(idx;1;LAMBDA(r;c;"space"));
newArr; VSTACK(DROP(spaces;1);listWk);
newArr
)
Sorry for ; separator instead of comma (my italian setup).
Believe me that every single step up to "idx" works as expected.
The problem is in "spaces" onward. If I use the "idx" variable in MAKEARRAY I only get 1 single extra row added. If I test with a fixed number (i.e. 4) instead of the "idx" variable, I get the expected result.
This is what I get (notice "space" text added to highlight the problem, and I know the code will return extra space even when not needed). Just to simply. Notice in column 22/02/2025 the idx variable properly returns 4 as result of the MATCH formula. But I only get 1 extra space from MAKEARRAY instead of 4.
Any clues?
Adding a link to a test workbook. https://docs.google.com/spreadsheets/d/1wfLMr9aeyL83CFK85KqUsKMjafmGsQRr/edit?usp=sharing&ouid=106172219459643397407&rtpof=true&sd=true





idxformula to, for exampleVALUE(IFNA(MATCH(firstRow;listWkBef;0);4));— in other words, are you sure thatidxis getting the correct value? Dates can be weird withMATCHandLOOKUP, because sometimes they are treated a Strings, sometimes as Numbers, etcdropis in lower case, but your other functions are all in upper case? You don't have a Named Range or something that shares the name with the function?dropas mentioned could be a reason if there is any named reference however i feel its a typo