Forum Discussion

Musketeers's avatar
Musketeers
Frequent Visitor
10 years ago
Solved

if else condition with between operator

Hi,

I am using M language and adding a new column in table.

I need to write if condition in this line.

I am writing if condition like this:

if [Month] between 2 and 4 then "yes" else "no"

 

Now here I am getting error for between key word. 

Please tell me what is the error and what is the correct way of writng this condition.

 

 

Thanks

Rajneesh

 

  • Hi

     

    You can do this

     

    if [Month] >= 2 and [Month] <= 4 then "yes" else "no"

     

     

     

    /Erik

7 Replies

  • Hi

     

    You can do this

     

    if [Month] >= 2 and [Month] <= 4 then "yes" else "no"

     

     

     

    /Erik

  • JPBTech19's avatar
    JPBTech19
    Frequent Visitor

    The following should work:

        IF
        (
            AND                                                   Operational condition
                (
                    [Month]>= 2, [Month]<=4        Conditional statement being evaluated
                ),

                "YES",                                             Result is condition is TRUE
                "NO"                                              Result is condition is FALSE
        )

     

    Written another way...

     

        IF(AND([Month]>= 2, [Month]<=4),"YES","NO")