How do I modify a 24-hour helper formula to include non-numerical values?

Options

I have a column with AM/PM times set up as a single select drop-down list. In order to make this column sortable, I created a helper column that converts the AM/PM times to 24 hour times. The formula in the helper column is as follows:

=VALUE(IF(VALUE(LEFT([Requested upload time]@row, FIND(":", [Requested upload time]@row) - 1)) <> 12, VALUE(LEFT([Requested upload time]@row, FIND(":", [Requested upload time]@row) - 1)) + IF(CONTAINS("p", [Requested upload time]@row), 12), IF(CONTAINS("p", [Requested upload time]@row), 12, 0)) + MID([Requested upload time]@row, FIND(":", [Requested upload time]@row) + 1, 2))

This formula works great, but the AM/PM drop-down list also has an option for 'No Preference.' Currently, if this option is selected, the helper column shows #INVALID VALUE. How can I modify the formula so the helper column will show 'No Preference' rather than #INVALID VALUE?

Tags:

Answers

  • Bassam Khalil
    Bassam Khalil ✭✭✭✭✭✭
    Options

    Hi @mgriffin

    please try the following.

    =IFERROR(VALUE(IF(VALUE(LEFT([Requested upload time]@row, FIND(":", [Requested upload time]@row) - 1)) <> 12, VALUE(LEFT([Requested upload time]@row, FIND(":", [Requested upload time]@row) - 1)) + IF(CONTAINS("p", [Requested upload time]@row), 12), IF(CONTAINS("p", [Requested upload time]@row), 12, 0)) + MID([Requested upload time]@row, FIND(":", [Requested upload time]@row) + 1, 2)),"No Preference")

    PMP Certified

    bassam.khalil2009@gmail.com

    ☑️ Are you satisfied with my answer to your question? Please help the Community by marking it as an ( Accepted Answer), and I will be grateful for your "Vote Up" or "Insightful"

  • Andrée Starå
    Andrée Starå ✭✭✭✭✭✭
    Options

    Hi @mgriffin

    I hope you're well and safe!

    Try something like this.

    =IF([Requested upload time]@row = "No Preference", [Requested upload time]@row, VALUE(IF(VALUE(LEFT([Requested upload time]@row, FIND(":", [Requested upload time]@row) - 1)) <> 12, VALUE(LEFT([Requested upload time]@row, FIND(":", [Requested upload time]@row) - 1)) + IF(CONTAINS("p", [Requested upload time]@row), 12), IF(CONTAINS("p", [Requested upload time]@row), 12, 0)) + MID([Requested upload time]@row, FIND(":", [Requested upload time]@row) + 1, 2)))

    Did that work/help?

    I hope that helps!

    Be safe and have a fantastic week!

    Best,

    Andrée Starå | Workflow Consultant / CEO @ WORK BOLD

    Did my post(s) help or answer your question or solve your problem? Please support the Community by marking it Insightful/Vote Up or/and as the accepted answer. It will make it easier for others to find a solution or help to answer!

    SMARTSHEET EXPERT CONSULTANT & PARTNER

    Andrée Starå | Workflow Consultant / CEO @ WORK BOLD

    W: www.workbold.com | E:andree@workbold.com | P: +46 (0) - 72 - 510 99 35

    Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.

  • Margaret Griffin
    Margaret Griffin ✭✭✭✭
    Options

    @Andrée Starå , I couldn't get your formula to work. It still returns an #INVALID VALUE response.

    @Bassam Khalil , your formula works perfectly. Thank you!

    But now I have another wrinkle. My team also wants to add 'CHALLENGE' as a drop-down value. The way Bassam's formula is written, I believe it's returning 'No Preference' when the cell being referenced has no numerical value. Is there a way to modify this formula to incorporate another non-numerical response?

    Thanks again to you both.

  • Andrée Starå
    Andrée Starå ✭✭✭✭✭✭
    Options

    @mgriffin

    Happy to help!

    I'd be happy to take a quick look.

    Can you maybe share the sheet(s)/copies of the sheet(s)? (Delete/replace any confidential/sensitive information before sharing) That would make it easier to help. (share too, andree@workbold.com)

    SMARTSHEET EXPERT CONSULTANT & PARTNER

    Andrée Starå | Workflow Consultant / CEO @ WORK BOLD

    W: www.workbold.com | E:andree@workbold.com | P: +46 (0) - 72 - 510 99 35

    Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.

  • Margaret Griffin
    Margaret Griffin ✭✭✭✭
    Options

    Hi @Andrée Starå I just shared a test sheet with you. https://app.smartsheet.com/sheets/HH3VM2qc3hHpfRCXFv76g622G5F9QRpC67qfMcc1

    This sheet only includes the original column and the helper column. The formula currently in use on the helper column is:

    =IF([Requested upload time]@row = "no preference", [Requested upload time]@row, VALUE(IF(VALUE(LEFT([Requested upload time]@row, FIND(":", [Requested upload time]@row) - 1)) <> 12, VALUE(LEFT([Requested upload time]@row, FIND(":", [Requested upload time]@row) - 1)) + IF(CONTAINS("p", [Requested upload time]@row), 12), IF(CONTAINS("p", [Requested upload time]@row), 12, 0)) + MID([Requested upload time]@row, FIND(":", [Requested upload time]@row) + 1, 2)))

    It works for all numerical values and one non-numerical value. Hopefully you can help modify it to work for all numerical values and two non-numerical values. Thanks again!

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!