Formulas and Functions

Formulas and Functions

Ask for help with your formula and find examples of how others use formulas and functions to solve a similar problem.

Whats wrong with this nested if and vlookup formula?

Hi - I am trying to have my smartsheet return the monthly budgeted cost for each test kit (covid, flu, strep, RSV. Each month has a different budget allocated to each test and these are in a separate sheet. I tried the formula below but it is returning as "unparseable". Can you please help me identify what I am doing wrong?

=IF([Test Type]@row = "Covid", VLOOKUP([Month/Year]@row, {Budgeted Cost Test Kits Range 1}, 2, false)), IF([Test Type]@row = "Flu", VLOOKUP([Month/Year]@row, {Budgeted Cost Test Kits Range 2}, 3, false)), IF([Test Type]@row = "Strep", VLOOKUP([Month/Year]@row, {Budgeted Cost Test Kits Range 3}, 4, false)), IF([Test Type]@row = "RSV", VLOOKUP([Month/Year]@row, {Budgeted Cost Test Kits Range 4}, 5, false))

Thanks

Comments

  • Community Champion

    You are closing out each IF statement before moving on to the next, but they need to be left open so that it is the "value if false" portion of the IF before. Notice the locations of the closing parenthesis in the below examples.

    You have

    =IF(this = this, do this), IF(that = that, do that)

    You should have

    =IF(this = this, do this, IF(that = that, do that))

  • ✭✭✭

    Awesome! That worked! Thank you so much!

  • Community Champion

    Happy to help. 👍️

    A quick tip: If you catch yourself repeating the same pieces of a formula over and over again with the only difference being a single variable based on an IF, you can nest the IF inside the other formula.

    =VLOOKUP([Month/Year]@row, {Budgeted Cost Test Kits Range 1}, nested IF to only output number based on test type, false)

    I personally would build out the nested IF first in one cell to just output the column number based on the test type. Then in another cell write the VLOOKUP and use a cell reference in it to reference the cell containing the nested IF. This will help you make sure everything is working as expected and makes troubleshooting a bit easier.

    Finally you would copy the entire nested IF (without the initial equals) and simply paste it into the VLOOKUP where the cell reference is. If you do this in a third column, troubleshooting is much much easier because you will know that the two individual pieces are working and you only need to figure out what is wrong with the nesting.

  • ✭✭✭

    Thank you. That is super helpful!

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!

Trending in Formulas and Functions

  • I have a pretty basic sheet that I am using to develop a formula, and am encountering an issue I haven't seen before. The formula isn't including my second row for some reason. It isn't a huge issue f…
    User: "jjg279"
    Answered ✓
    9
    2
  • I'm sure that this is an easy fix but I've tried a bunch of different ways and can't get this to work. I need to get the max date from a sheet to feed it into my meta data sheet (dates are stored in d…
    User: "susanmgfin"
    Answered ✓
    8
    2
  • I need help to come up with the risk formula. I tried many different formulas and tried to modify it but just can't seem to have desired results. So these are the conditions I MUST meet: Program is a …
    User: "Ronak"
    Answered ✓
    29
    6