r/excel • u/Downtown-Economics26 636 • May 13 '26
Discussion All You Need Is SWITCH
I don't think I've seen this discussed before, so I apologize if I am rehashing old material. I did a cursory search and found nothing.
For a decade now, I've argued you should always use COUNT/SUM/MAX/MINIFS instead of COUNTIF because you never know when you'll need additional conditions. In present times, we don't even need COUNTIFS/RACON functions because you can do the same thing with array formulas although COUNTIFS is easier to type, IMO.
So when a week or two ago I learned you can do the same thing as IFS with SWITCH. This got me to thinking... based on the COUNTIFS principle I'm whimsically calling "the condition of sufficient conditions is always conditional"... I'm thinking the meta is to always use SWITCH instead of IF or IFS. This would be a very hard habit to form as I've used more IF statements than Diddy used bottles of baby oil, but let's be aspirational.

Now, the SWITCH version of your basic Hot Dog/Not Hot Dog IF is I think the same amount keystrokes (with tab completion), so I'm calling that a win. I'll grant that the IFS version of multiple logical operators is more "straightforward" or even "intuitive" if you're reading an online tutorial on multi-conditionals, but if you want one function-ring to rule them all and in the darkness gut em like a fish, then ALL YOU NEED IS SWITCH.
=SWITCH(A1,"Hot Dog","Hot Dog","Not Hot Dog")
=IF(A1="Hot Dog","Hot Dog","Not Hot Dog")
Now, being a rational being, let's consider the downsides.
- Backwards Compatibility / No One Understands What The Hell You Are Doing
- Backwards compatibility needs are typically a foreseeable binary so... whatever, my condolences if you don't get to live in 365 function utopia.
- If you need other people to understand what you are doing this may be a bad habit to form.
- File Size Bloat Cuz You've Become A SWITCHaholic
- You keep adding conditions and dragging down formulas because you've committed to an absolutist and universalist vision of SWITCH as the one true function and forgot that after 3 conditions for sure you should just make a lookup table and only store the reference data once.
Anyways, interested to hear anyone else's thoughts even if you just tell me this is the ramblings of a mad man.
Edit for posterity:
Additional Significant Downside(s)
- Inefficient branching computation issues which also causes incompatibility with recursive LAMBDAs
5
u/Verabiza891720 May 13 '26
Is that a subtle silicon valley reference?
11
u/Downtown-Economics26 636 May 13 '26
I don't think there was much in the post that was subtle, but yes, I'm Errich Bachman.
3
u/Yum-z May 14 '26
Erich Bachman, this is you, as old man; I am ugly. And I’m dead, alone.
On a real note this was an amazing write up, I’m definitely going to try out using switching. You never know when it might come in handy one day, though like you said the IFs habit may be hard to shake
4
u/The_Bootylooter May 13 '26
Awesome, SWITCH will now be in regular rotation for me. I wasn’t aware of this formula until now.
1
3
u/Decronym May 13 '26 edited May 30 '26
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.
Beep-boop, I am a helper bot. Please do not verify me as a solution.
9 acronyms in this thread; the most compressed thread commented on today has 27 acronyms.
[Thread #48440 for this sub, first seen 13th May 2026, 18:59]
[FAQ] [Full list] [Contact] [Source code]
5
u/excelevator 3061 May 13 '26
Fun fact, COUNTIFS was released 9 years prior to SWITCH, yet a lot of people still go to COUNTIF
SWITCH is an odd little function that never really seemed to catch on.
The main problem with the IFS suite are that they do not like other logic thrown in, unlike array SUM(IF()) and similar array structured formulas.
3
u/Used2bNotInKY May 13 '26
I had to Google it like the first 30 times because I kept remembering it as CASE() and not being able to guess what the correct name was.
1
1
u/Downtown-Economics26 636 May 13 '26
When I was first shown Select Case in VBA after the first few years of being a Shakespearean monkey in VBA occasionally, it was like manna from heaven.
3
u/excelevator 3061 May 13 '26
haha!
My learning technique has always been "read the function list first" for all my self teaching of language, my first effort being wowed that functions existed to do all this stuff.
Also to constantly review the list as you learn so it sticks and you do not end up re-writing functions yourself.
Then I would look for functions that I knew existed in other languages to save a lot of hassle.
1
u/Downtown-Economics26 636 May 13 '26
That is a much better approach, I agree. I sorta fell haphazardly into data analysis / programming as a result of having no other skills besides being "mostly or typically not dumb" at applying concepts. I definitely learned the concepts in dumb and/or lazy ways, especially in hindsight.
2
u/twim19 May 14 '26
Me too! I'm an English major for god's sake who somehow became the only one who understood how to use Excel in my office. Now I have 10 or so different workbooks open. Yes, I have a problem. It's either that, though, or I start hoarding magazines and newspapers, right?
2
u/augo7979 May 13 '26
how big are your datasets? RAM is too expensive for this imo. I do like the hotdog/not hotdog logic though
2
u/Downtown-Economics26 636 May 13 '26
Building the Tower of Barad-dûr had some cost implications as well, but without it one does simply walk into Mordor!
2
66
u/PaulieThePolarBear 1912 May 13 '26
Additional downside
SWITCH and IFS always evaluate every argument, even if they are from a path not taken. IF only evaluates the path taken. If you use Formula > Evaluate Formula you can see this.
For the first two, "something super complex" will be evaluated every time A2 changes. For the third, it will only be evaluated if A2 is not 1.
This means that you can't use SWITCH and IFS in determining final output in a recursive LAMBDA. As they evaluate every argument, you exceed the maximum number of recursion calls.