Using a nested IF to determine a range
Here's a little tid-bit I just figured out today... You can use a nested IF statement to output ranges/cross sheet references that are to be evaluated.
The particular use case that led to this was an INDEX/MATCH where we wanted to INDEX on a single date column, but MATCH on one of 4 different columns depending on an Asset Type. We ended up being able to use a nested IF for the "range to search in" portion of the MATCH.
=INDEX({Asset Checkout Range 3}, MATCH(Barcode@row, IF([Asset Type]@row = "Camera", {Asset Checkout Range 1}, IF([Asset Type]@row = "Support", {Asset Checkout Range 2}, IF([Asset Type]@row = "Lighting", {Asset Checkout Range 5}, {Asset Checkout Range 6}))), 0))
I personally like this a little better than writing out four different INDEX/MATCH statements and using IFERRORs to account for the #NO MATCH issue which would have looked like this...
=IFERROR(IFERROR(IFERROR(INDEX({Asset Checkout Range 3}, MATCH(Barcode@row, {Asset Checkout Range 1}, 0)), INDEX({Asset Checkout Range 3}, MATCH(Barcode@row, {Asset Checkout Range 5}, 0))), INDEX({Asset Checkout Range 3}, MATCH(Barcode@row, {Asset Checkout Range 1}, 0))), INDEX({Asset Checkout Range 3}, MATCH(Barcode@row, {Asset Checkout Range 6}, 0)))
We saved 93 characters/keystrokes and only had to reference the INDEX range and the "data to match on" for the MATCH function once each instead of 4 times, and I can't say for sure, but I also feel like this might be a little more efficient on the back-end as well.
I feel like there are a lot more practical applications too.
Here is a link to the thread that prompted this...
Comments
-
Well, this is amazing. Thank you for sharing, @Paul Newcome!!
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
I just can't believe I never tried it before. I would normally have gone the IFERROR route, but the thought didn't even cross my mind this time. I'm glad it didn't because I like this way better. Haha
-
Very Nice! This reminded me of something, and I spent 20 minutes trying to find our discussion about it haha.
https://community.smartsheet.com/discussion/29386/unexpected-behavior-with-collect-formula#latest
-
@L@123 Haha. I completely forgot about that one. Here in a few days it will be exactly 3 years ago. Hahaha.
I still haven't completely wrapped my head around the logic of that one. Maybe I need to just build out a sheet and paste your formula in so I can play around with it myself.
-
@Paul Newcome I"m not sure if it works the same as back then. That whole project pretty much got wiped when they added the move/copy row functionality. I'm going to play around with it a bit. I deleted all the original files, so i'd have to recreate it.
-
it works even better than it used to. Now you can just slap a "true" in there and it works like a charm.
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 434 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives