IF statement - why can't I see the issue??

%3CLINGO-SUB%20id%3D%22lingo-sub-2211055%22%20slang%3D%22en-US%22%3EIF%20statement%20-%20why%20can't%20I%20see%20the%20issue%3F%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2211055%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Guys%2C%20this%20should%20be%20an%20easy%20one%2C%20yet%20I%20am%20so%20stuck.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20write%20an%20IF%20statement%20that%20will%20return%20categories%2C%2030%20minutes%20or%20under%2C%20between%2031%20and%2060%20minutes%2C%20between%2061%20and%2090%20minutes%2C%20between%2091%20and%20120%20minutes%20and%20over%20120%20minutes.%3C%2FP%3E%3CP%3EI%20can't%20workout%20what%20I%20am%20doing%20wrong%3F%3F%3C%2FP%3E%3CP%3E%3DIF(E2%26lt%3B31%2C%22less%20than%2030%20minutes%22%2CIF(E2%26gt%3B%3D31%26lt%3B%3D60%2C%22Between%2031%20and%2060%22%2CIF(E2%26gt%3B%3D61%26lt%3B%3D90%2C%22Between%2061%20and%2090%22%2CIF(E2%26gt%3B%3D91%26lt%3B%3D120%2C%22Between%2091%20and%20120%22%2C%22Greater%20than%20120%22))))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20advice%20is%20greatly%20appreciated%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2211055%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2211191%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20statement%20-%20why%20can't%20I%20see%20the%20issue%3F%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2211191%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F997762%22%20target%3D%22_blank%22%3E%40Mel_Dyson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20condition%20such%20as%20E2%26gt%3B%3D31%26lt%3B%3D60%20is%20not%20valid%20in%20Excel.%20Do%20it%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIF(E2%26lt%3B%3D30%2C%2230%20minutes%20or%20less%22%2CIF(E2%26lt%3B%3D60%2C%22Between%2031%20and%2060%22%2CIF(E2%26lt%3B%3D90%2C%22Between%2061%20and%2090%22%2CIF(E2%26lt%3B%3D120%2C%22Between%2091%20and%20120%22%2C%22Greater%20than%20120%22))))%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi Guys, this should be an easy one, yet I am so stuck.

 

I'm trying to write an IF statement that will return categories, 30 minutes or under, between 31 and 60 minutes, between 61 and 90 minutes, between 91 and 120 minutes and over 120 minutes.

I can't workout what I am doing wrong??

=IF(E2<31,"less than 30 minutes",IF(E2>=31<=60,"Between 31 and 60",IF(E2>=61<=90,"Between 61 and 90",IF(E2>=91<=120,"Between 91 and 120","Greater than 120"))))

 

Your advice is greatly appreciated  

6 Replies

@Mel_Dyson 

 

A condition such as E2>=31<=60 is not valid in Excel. Do it like this:

 

=IF(E2<=30,"30 minutes or less",IF(E2<=60,"Between 31 and 60",IF(E2<=90,"Between 61 and 90",IF(E2<=120,"Between 91 and 120","Greater than 120"))))

@Mel_Dyson 

 

I didn't try to diagnose what you were doing wrong. I'll just say in general that nesting a lot of IF functions always gets tricky. It's probably why Excel now offers an IFS function.

 

This one works for you
=IFS(E2<31,"less than 30 minutes",E2<=60,"Between 31 and 60",E2<=90,"Between 61 and 90",E2<=120,"Between 91 and 120",E2>120,"Greater than 120")

 

What it does is to stop calculating once a condition is met. The general syntax is

IFS(condition1, result1,condition2,result2,condition3,result3.......)

@Mel_Dyson 

As variant

=LOOKUP(E2,
  {0,31,61,91,121},
  {"less than 30 minutes","Between 31 and 60","Between 61 and 90","Between 91 and 120","Greater than 120"}
)
oh to think that is what it was! Thank you so very much I really appreciate it! Have a wonderful week!
Thank you so very much - I get it, great explanation. Have a great week!
Excellent value add thank you Sergei! I've noted that option down for future reference. Have a great week!