Index/Collect/Lookup not working

LFoster
LFoster ✭✭✭

I've put together a function that pulls an autonumber value from a cross-reference. The problem is that the formula does not evaluate on all records. In the first snippet below the Row Record field does not return a value for all lookup values in the Base PO field even though I have confirmed that all the lookup values exist in the reference sheet. On top of that, if I enter a new record in the reference sheet with a new dummy Base PO the 2 records that originally returned a value in the Row Record field in the first snippet now do not. I can't understand why the formula either works for all or none. The only problem field for me is the Row Record field as all other error fields lookup that value.

image.png image.png

Formula:

=IF([Requested POs]@row = "", "", IF([Next Appointment Date]@row = "", "", INDEX(COLLECT({108 Inbound Detail Grid - Row Record}, {108 Inbound Detail Grid - PO No Suffix}, CONTAINS([Base PO]@row, @cell), {108 Inbound Detail Grid - Status}, OR(@cell = "Scheduled", @cell = "Unassigned", @cell = "Unloading"), {108 Inbound Detail Grid - App Date}, [Next Appointment Date]@row, {108 Inbound Detail Grid - Appointment Time Decimal}, @cell = MIN({108 Inbound Detail Grid - Appointment Time Decimal})), MATCH([Next Appointment Date]@row, {108 Inbound Detail Grid - App Date}, 0))))

Tags:

Best Answer

  • Paul Newcome
    Paul Newcome Community Champion
    Answer βœ“

    I feel like it may be how we are pulling in the MIN value for the decimal.


    =IF([Requested POs]@row = "", "", IF([Next Appointment Date]@row = "", "", INDEX(COLLECT({108 Inbound Detail Grid - Row Record}, {108 Inbound Detail Grid - PO No Suffix}, CONTAINS([Base PO]@row, @cell), {108 Inbound Detail Grid - Status}, OR(@cell = "Scheduled", @cell = "Unassigned", @cell = "Unloading"), {108 Inbound Detail Grid - App Date}, [Next Appointment Date]@row, {108 Inbound Detail Grid - Appointment Time Decimal}, @cell = MIN({108 Inbound Detail Grid - Appointment Time Decimal})), 1)))


    You are pulling in the smallest decimal value, but the MIN is not also being filtered by the same range/criteria sets. I have run into issues before putting a COLLECT inside of a COLLECT, so let's try moving the MIN function into its own column.

    Helper column on formula sheet:

    =MIN(COLLECT({108 Inbound Detail Grid - Appointment Time Decimal}, {108 Inbound Detail Grid - PO No Suffix}, CONTAINS([Base PO]@row, @cell), {108 Inbound Detail Grid - Status}, OR(@cell = "Scheduled", @cell = "Unassigned", @cell = "Unloading"), {108 Inbound Detail Grid - App Date}, [Next Appointment Date]@row))


    Then adjust the main formula like so:

    =IF([Requested POs]@row = "", "", IF([Next Appointment Date]@row = "", "", INDEX(COLLECT({108 Inbound Detail Grid - Row Record}, {108 Inbound Detail Grid - PO No Suffix}, CONTAINS([Base PO]@row, @cell), {108 Inbound Detail Grid - Status}, OR(@cell = "Scheduled", @cell = "Unassigned", @cell = "Unloading"), {108 Inbound Detail Grid - App Date}, [Next Appointment Date]@row, {108 Inbound Detail Grid - Appointment Time Decimal}, @cell = [Helper Column]@row), 1)))

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!