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
-
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!
-
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
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 66.5K Get Help
- 432 Global Discussions
- 152 Industry Talk
- 494 Announcements
- 5.3K Ideas & Feature Requests
- 85 Brandfolder
- 155 Just for fun
- 76 Community Job Board
- 504 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 307 Events
- 37 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!