Forum Discussion

Giovani's avatar
Giovani
Helper I
7 years ago
Solved

Condition with AND

Hi, 

 

I am trying to create new column based on a previous one based with the condition if less then 10 = 1 ; if between 10 and 49 = 2 ; and if great then 50 = 3. 

The desired output would be:

Item Total NewVariable
Product A11
Product B242
Product C482
Product D563

 

The code I am using is: 

NewVariable = SWITCH(
TRUE(),
'Value'[Total] <= 10,
Value(1),
'Value'[Total] > 10 and 'Value'[Total] <50,
Value(2),
'Value'[Total] >= 50,
Value(3),
-1)
 
but it is not working any thoughts how I could overpass this?
Thanks,
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi Giovani ,

     

    Try this code.

     

    Column = SWITCH(True(),
                     'Value'[Total ]<=10,1,
                     'Value'[Total ]>10
                        && 'Value'[Total ]<50, 2, 'Value'[Total ]>=50,3,
                                -1)
     
     
     
    It has worked for me and here is my output:
     
     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Giovani ,

     

    Try this code.

     

    Column = SWITCH(True(),
                     'Value'[Total ]<=10,1,
                     'Value'[Total ]>10
                        && 'Value'[Total ]<50, 2, 'Value'[Total ]>=50,3,
                                -1)
     
     
     
    It has worked for me and here is my output: