Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

SWITCH statement in Google Sheets Doesn't Compare Strings Properly?

$
0
0

I have a very simple SWITCH statement in Google Sheets:

=switch(    D2,"",B2,    D2,"A","A",    D2,"B","B","Default"    )

If I put any non-blank value in D2, I always get A back, even if I put B or anything else (one or more characters). If I leave D2 blank, I correctly get B2's value. It's as if any non-blank string is equal to "A" as SWITCH does the comparison. But that's certainly not what the documentation and many other websites offering examples of SWITCH say should happen.Is this a bug in Sheets or what am I misunderstanding?

My real use case is far more than 3 cases, so please don't advise me to use nested IFs instead.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>