Forum Discussion
Giovani
7 years agoHelper I
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 A | 1 | 1 |
| Product B | 24 | 2 |
| Product C | 48 | 2 |
| Product D | 56 | 3 |
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,
- Anonymous7 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
- AnonymousNot 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: