Home » excel » excel – case statement in a spreadsheet

excel – case statement in a spreadsheet

Posted by: admin May 14, 2020 Leave a comment

Questions:

So,
what i am trying to accomplish here is pretty straight forward, i have a column fare in my spreadsheet and i want to add anew column that would say if the fare is <10 ,10<20,20<30,30+

I came up with this solution but it seems like it is not using a shortcut condition, is there a case statement or any other method i can use to achieve what i want?

=if(J19<10,”<10″,IF(AND(J19>10,J19<20),”10<20″,IF(AND(J19>20,J19<30),”20<30″,”30+”
)))

How to&Answers:

Try something like this:

=ROUNDDOWN(A1,-1)&"<"&ROUNDUP(A1,-1)

Answer:

Since the conditions in a nested set of if functions are evaluated consecutively, you do not need to repeat previous conditions using and. Also note that your original formula doesn’t do the right thing at the borderlines, e.g. if J19=10.

So although Excel does not have a case function, the following is simpler and more accurate than your original:

=if(J19<10,"<10",IF(J19<20,"10<20",IF(J19<30,"20<30","30+")))