Forum Discussion

leolapa's avatar
leolapa
Brass Contributor
Sep 08, 2021

Replace #N/A with prior available values on a 2D running array with ONE "spill" formula

Below is a small sample from close market prices for 3 stock tickers using the STOCKHISTORY function: I realized that when no data is available for a particular stock, it then returns the #N/A...
  • tboulden's avatar
    tboulden
    Sep 08, 2021

    leolapa  Ahh, sorry, misunderstood. This solution handles that case, however if the very first entry is an error, it will show the errors; only if there is a prior non-error value in the column will it show the value.

    =LET(
        rng,$B$2:$D$11,
        rows_,SEQUENCE(ROWS(rng)),
        nonerror_rows,--(NOT(ISERROR(rng)))*rows_,
        working_rows,
            MAKEARRAY(
                ROWS(nonerror_rows),
                COLUMNS(nonerror_rows),
                LAMBDA(i,j,
                    MAX(
                        1,
                        IF(
                            i=1,INDEX(nonerror_rows,i,j),
                            MAX(
                                INDEX(nonerror_rows,SEQUENCE(i),j)
                            )
                        )
                    )
                )
            ),
        INDEX(rng,working_rows,SEQUENCE(,COLUMNS(rng)))
    )

     

    This is very similar to my answer on your prior post for last matching row.

Resources