+ Reply to Thread
Results 1 to 6 of 6

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

  1. #1
    Registered User
    Join Date
    11-27-2015
    Location
    Sao Paulo, Brazil
    MS-Off Ver
    MS Office 365
    Posts
    42

    Question 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:
    Data.png
    I realized that when no data is available for a particular stock, it then returns the #N/A error.

    The problem for me is that it screws up my day-to-day % variance calculation, among other things, so I want to replace those #N/A's with the last available trading day's price, like the screenshot below:
    Goal.png
    But here's the catch: only a single-cell "spill" formula will work for me. On the above screenshot, it needs to be a formula on cell "AQ2" that "spills" the values down and across, the same way the STOCKHISTORY function works.

    Since I don't know a way to make the STOCKHISTORY function do that #N/A replacement job in and of itself, albeit it would be GREAT if it could, I had to find a workaround to make that happen for me.

    So I did a couple of calculation steps in order to get the row numbers array that would serve as input to the final INDEX function, and managed to get to a 1D "spill" solution for each of the 3 individual tickers columns on that example, as shown below (I just don't know how to trick those 3 yellow-shaded validation arrays into one consolidated formula without returning error):
    1D_Spill_Row_Num.png
    The couple areas highlighted in red indicate the rectified row numbers that will serve as replacements for the #N/A's that have prior values to be used on their places.
    However the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    only treats each column individually, and that's the piece that I'm missing to get to my final goal...
    ... which is the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    that produces the final array previously shown:
    2D_Spill_NA_Repl.png

    If I can get that row number formula to work down and across a 2D range, then I would be able to replace that "$AM$2:$AO$11" piece of the INDEX function with the hash reference "$AM$2#" and therefore get this baby kicking and screaming across the finish line.
    2D_Spill_NA_Repl_Complete.png

    Any ideas/suggestions on how to finesse that intermediate formula?

    Thanks in advance...

    P.S.:
    As usual I also post the same question under the Microsoft Tech Community forum, which is available on the link that follows:
    HTML Code: 
    Last edited by leolapa; 09-08-2021 at 09:56 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,836

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

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    11-27-2015
    Location
    Sao Paulo, Brazil
    MS-Off Ver
    MS Office 365
    Posts
    42

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

    You just read my mind as I was just trying to do that since I was unable to do so during the original posting (probably because I reached a limit due to the 5 screenshots I had already attached in the message body).

    I'll do that now. Thanks!
    Last edited by leolapa; 09-08-2021 at 10:01 AM.

  4. #4
    Registered User
    Join Date
    11-27-2015
    Location
    Sao Paulo, Brazil
    MS-Off Ver
    MS Office 365
    Posts
    42

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

    Another user on the Microsoft Tech Community forum was kind enough to provide a pretty nice solution making use of the newly added MAKEARRAY function:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

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

    Try

    =LET(z;B2:D11;se;SEQUENCE(ROWS(z));INDEX(z;MID(BYCOL(z;LAMBDA(z;CONCAT(TEXT(IFERROR(LOOKUP(se;se/ISNUMBER(z));se);"000"))));se*3-2;3);SEQUENCE(;COLUMNS(z))))

  6. #6
    Registered User
    Join Date
    11-27-2015
    Location
    Sao Paulo, Brazil
    MS-Off Ver
    MS Office 365
    Posts
    42

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

    Quote Originally Posted by Bo_Ry View Post
    Try

    =LET(z;B2:D11;se;SEQUENCE(ROWS(z));INDEX(z;MID(BYCOL(z;LAMBDA(z;CONCAT(TEXT(IFERROR(LOOKUP(se;se/ISNUMBER(z));se);"000"))));se*3-2;3);SEQUENCE(;COLUMNS(z))))
    Works great! Thanks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Find last MATCH for each row on a 2D running array with ONE "spill" formula
    By leolapa in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2021, 11:34 AM
  2. [SOLVED] Extract unique lists of sorted data across columns (2D arrays) with ONE "spill" formula
    By leolapa in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-01-2021, 09:58 AM
  3. [SOLVED] Data sorting multiple rows across columns (2D arrays) with only ONE "spill" formula
    By leolapa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-24-2021, 01:40 PM
  4. [SOLVED] Return MAX (or LARGE) for each 2D array's row with only ONE "spill" formula
    By leolapa in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-22-2021, 08:50 AM
  5. [SOLVED] Brief formula to convert time values to "shift1", "shift2", "shift3".
    By darekpawel in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 04-11-2019, 07:05 AM
  6. Replies: 3
    Last Post: 03-13-2012, 11:33 AM
  7. [SOLVED] If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ...
    By Maria J-son in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2006, 08:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1