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
Anonymous
Not applicable

Using SWITCH with IN

Hello Community    -    This is a new thread for the same topic.   Previously I was trying a different formula, but ultimately I think SWITCH might be better as I have two variable that I need to check  (different columns, but same table). 

 

First, I need to check if the Product Code fits a certain criteria.    Second, I need to check if the ITEM description contains (anywhere) the text  "-1".    

 

This formula below only works if I do not include the IN statements.    All I get returned is  "NA".      Just trying to figure out how to include the IN statment, or some other formula that gets to the result below. 

 

The goal would be to return this result, if the row item met the criteria.

 

Product Code          Item                              SKU Type

CODE123            AB-23-45-1-X               Standard SKUs

 

SKU Type =  SWITCH(
TRUE(),
'Flu_Shipped Query'[Product Code] = "CODE123" && 'Flu_Shipped Query'[Item] IN {"-1"}, "Standard SKUs",
'Flu_Shipped Query'[Product Code] = "CODE346" && 'Flu_Shipped Query'[Item] IN {"-1"}, "Standard SKUs",
'Flu_Shipped Query'[Product Code] = "CODE782" && 'Flu_Shipped Query'[Item] IN {"-1"}, "Standard SKUs",
"NA")
1 ACCEPTED SOLUTION
Tahreem24
Super User
Super User

@Anonymous ,

Try to use Search or Find DAX:

SKU Type =  SWITCH(
TRUE(),
'Flu_Shipped Query'[Product Code] = "CODE123" && SEARCH("-1",'Flu_Shipped Query'[Item]),"Standard SKUs",
 . . . )
Please complete your formula like above.
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

4 REPLIES 4
vanessafvg
Super User
Super User

have you checked your data? i have run this on some test data and your code works fine, maybe your data doesn't support your condition?

 

see attached





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Tahreem24
Super User
Super User

@Anonymous ,

Try to use Search or Find DAX:

SKU Type =  SWITCH(
TRUE(),
'Flu_Shipped Query'[Product Code] = "CODE123" && SEARCH("-1",'Flu_Shipped Query'[Item]),"Standard SKUs",
 . . . )
Please complete your formula like above.
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

@Tahreem24     Thanks Tahreem, but I am getting the following error: 

 

The search Text provided to function 'SEARCH' could not be found in the given text

@Anonymous ,

There is a simplied version of DAX. I've created same sample like you and also attached the screen shot below with DAX and expected output.

Hope it may help you.

Capture.PNG

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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.