Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Giovani
Helper I
Helper 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 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,
1 ACCEPTED SOLUTION
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:
Capture11.PNG
 
 

View solution in original post

1 REPLY 1
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:
Capture11.PNG
 
 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.