Forum Discussion

laurelb2003's avatar
laurelb2003
Copper Contributor
Jul 14, 2023

Trying to write a logical formula

Hi

 

I'm trying to write a logical formula for the first time and am not succeeding.

 

The formula needs to work as follows:

 

if the value is less than 12, then 2.0

if the value is 12 to less than 18, then 1.5

if the value is 18 or more, then 1.25

 

I appreciate any help that can be offered.

 

Thank you 

6 Replies

  • flexyourdata's avatar
    flexyourdata
    Iron Contributor

    laurelb2003 

     


    if the value is less than 12, then 2.0

    if the value is 12 to less than 18, then 1.5

    if the value is 18 or more, then 1.25

     

    Suppose the value is in cell A1. Here are several options you can try:

    1) Using IFS

     

    =IFS(A1<12,2,A1<18,1.5,TRUE,1.25)

     

     2) Using nested IF

     

    =IF(A1<12,2,IF(A1<18,1.5,1.25))

     

    3) Using XLOOKUP

     

    =XLOOKUP(A1,{0,12,18},{2,1.5,1.25},,-1)

     

     

    • laurelb2003's avatar
      laurelb2003
      Copper Contributor
      Hi. This isn't actually working. Should A be the letter of the cell number the height is in? I tried that and A and every height is coming out with the same answer
    • laurelb2003's avatar
      laurelb2003
      Copper Contributor
      That works. Thank you. I just had to change the True in the IFS to 2.
    • laurelb2003's avatar
      laurelb2003
      Copper Contributor
      Thank you. When I try this I get 2 for every value. Is there something else I need to do?

Resources