Search code examples
if-statementgoogle-sheetslogicarray-formulaslogical-operators

Converting if/and statement into an array formula


I'd like to convert the following formula:

=IF(A2:A=1,"Under an hour",IF(AND(A2:A<48,A2:A>23),"1 Day",IF(A2:A>=24,int(A2:A/24)&" Days",ROUNDUP(A2:A) &" Hours")))

into an Array formula. Currently it doesn't work because AND statements don't work in Array Formulas but I'm not really sure how to get it working without the and (and without embedding 24 different IF statements)

I basically just want to return user-readable text in column B relating to how many hours are shown in A:

0   0 Hours
1   Under an hour
2   2 Hours
23  23 Hours
24  1 Day
25  1 Day
47  1 Day
48  2 Days
49  2 Days
100 4 Days

Solution

  • Change AND(A2:A<48,A2:A>23) to (A2:A<48)*(A2:A>23):

    enter image description here