Index/Collect for last non blank value looping

Options

I'm trying to get the last non blank date value if the value that pulls is blank. We have a sheet that make a separate line for each part of a process, and has the dates for each start. The "Start Date" column should fill with the date that corresponds to the Index for that Run. In the below example, they have a start date for Run 1 and Run 3, but not for 2, 4, or 5.


I'm able to get the "Start Date" to fill if the current run is blank, but the row above it has a date (example, run 2 pulls run 1's date and run 4 pulls run 3's date). Is there a way to get the formula to keep looping if the pulled value is also blank (example, run 5 would pull run 4, but that's blank).


Formula I have written now:

=IF([Start Date]@row <> "", INDEX(COLLECT([Start Date]:[Start Date], [Project Name]:[Project Name], [Project Name]@row), Index@row), INDEX(COLLECT([Start Date]:[Start Date], [Project Name]:[Project Name], [Project Name]@row), Index@row - 1))



Thanks!

Answers

  • Lucas Rayala
    Lucas Rayala ✭✭✭✭✭✭
    edited 07/01/23
    Options

    Hi @mwat4482, this should work:

    =INDEX(COLLECT([Start Date]:[Start Date], [Project Name]:[Project Name], [Project Name]@row, [Start Date]:[Start Date], <>"", Index:Index, <=Index@row), 1)

  • mwat4482
    Options

    Hi @Lucas Rayala,

    That's causing it to pull the date on the 1st run, even if that run has a date or the run before it has a date. Do you know how to get it to populate with the index before it, not index 1?

  • Lucas Rayala
    Lucas Rayala ✭✭✭✭✭✭
    Options

    Hi @mwat4482, sorry about the lag in response. I think I see what you're asking now. Can you try this?


    =INDEX([Start Date]:[Start Date], MATCH(MAX(COLLECT(Index:Index, [Project Name]:[Project Name], [Project Name]@row, [Start Date]:[Start Date], <>"", Index:Index,<=Index@row)), Index:Index,0))

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!