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
dakins
Helper II
Helper II

If statement with multiple OR and AND not working

IF('Product(FT)'[Color_Type] = "White" &&
'Product(FT)'[sub_Name] = "SFSA 7.2" ||
'Product(FT)'[sub_Name] = "SFSA 8.0" ||
'Product(FT)'[sub_Name] = "SFSA 8.1" ||
'Product(FT)'[sub_Name] = "SFSA 9" &&
'Product(FT)'[Reg_Create].[Date] >= DATEVALUE("04/02/2021"), "1250.00",

IF('Product(FT)'[Color_Type] = "White" &&
'Product(FT)'[sub_Name] = "SFSA 7.2" ||
'Product(FT)'[sub_Name] = "SFSA 8.0" ||
'Product(FT)'[sub_Name] = "SFSA 8.1" ||
'Product(FT)'[sub_Name] = "SFSA 9" &&
'Product(FT)'[Reg_Create].[Date] < DATEVALUE("04/02/2021"), "1000.00",

IF('Product(FT)'[Color_Type] = "Black" &&
'Product(FT)'[sub_Name] = "SFSA 7.2" ||
'Product(FT)'[sub_Name] = "SFSA 8.0" ||
'Product(FT)'[sub_Name] = "SFSA 8.1" ||
'Product(FT)'[sub_Name] = "SFSA 9" &&
'Product(FT)'[Reg_Create].[Date] >= DATEVALUE("04/02/2021"), "50.00

IF
('Product(FT)'[Color_Type] = "Black" &&
'Product(FT)'[sub_Name] = "SFSA 7.2" ||
'Product(FT)'[sub_Name] = "SFSA 8.0" ||
'Product(FT)'[sub_Name] = "SFSA 8.1" ||
'Product(FT)'[sub_Name] = "SFSA 9" &&
'Product(FT)'[Reg_Create].[Date] < DATEVALUE("04/02/2021"), "25.00","0.00"
))))
 
My desired result is:
If product color equals white AND product name equal SFSA 7.2 or SFSA 8.0 or SFSA 8.1 or SFSA 9 AND
product registration date is greater or equal to
04/02/2021 then price should be 1,250.
If product color equals white AND product name equal SFSA 7.2 or SFSA 8.0 or SFSA 8.1 or SFSA 9 AND
product registration date is less than
04/02/2021 then price should be 1,000.
 
If product color equals black AND product name equal SFSA 7.2 or SFSA 8.0 or SFSA 8.1 or SFSA 9 AND
product registration date is greater or equal to
04/02/2021 then price should be 50.

If product color equals Black AND product name equal SFSA 7.2 or SFSA 8.0 or SFSA 8.1 or SFSA 9 AND
product registration date is less than
04/02/2021 then price should be 25 else 0
 
 
I have no errors but the calculated column isn't working like it supposed to. The prices do not work as proposed
 
 
Thank you
 
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@dakins , You can use switch True()

You can cover OR like

'Product(FT)'[sub_Name]  in { "SFSA 7.2" , "SFSA 8.0" , "SFSA 8.1" ,"SFSA 9"}

 

Example

Switch( True() ,

'Product(FT)'[Color_Type] = "White" &&

'Product(FT)'[sub_Name]  in { "SFSA 7.2" , "SFSA 8.0" , "SFSA 8.1" ,"SFSA 9"}&&
'Product(FT)'[Reg_Create].[Date] >= DATEVALUE("04/02/2021"), "1250.00",

// Add other condition

"1250.00" //default value

)

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

 

View solution in original post

2 REPLIES 2
dakins
Helper II
Helper II

Thank you! thank you! thank you! @amitchandak

amitchandak
Super User
Super User

@dakins , You can use switch True()

You can cover OR like

'Product(FT)'[sub_Name]  in { "SFSA 7.2" , "SFSA 8.0" , "SFSA 8.1" ,"SFSA 9"}

 

Example

Switch( True() ,

'Product(FT)'[Color_Type] = "White" &&

'Product(FT)'[sub_Name]  in { "SFSA 7.2" , "SFSA 8.0" , "SFSA 8.1" ,"SFSA 9"}&&
'Product(FT)'[Reg_Create].[Date] >= DATEVALUE("04/02/2021"), "1250.00",

// Add other condition

"1250.00" //default value

)

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

 

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.