cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
snipesnab
Helper II
Helper II

If Collection column CONTAINS words "laptop" or "Desktop" then set variable value

Hi PowerAppers,

 

I have a collection with a column called 'ItemType'.

I would like to check if the value "Laptop" or "Desktop" is CONTAINED within the text of the column, and if so set the value of varRecord to "Yes".

 

I am struggling to understand how to construct this, please help?

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@snipesnab 

Consider the following formula:

Set(varRecord,
   If(
       LookUp(yourCollection, 
           "Laptop" in ItemType ||
           "Desktop" in ItemType,
           true
       ),
       "Yes", 
       "No"
   )
)
     

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

snipesnab
Helper II
Helper II

I think I solved the problem with the following code:

 

If(CountRows(Filter(ShoppingCart,"Laptop" in 'ItemType'))>0,
Set(varCMDB,"yes"),Set(varCMDB,"no")
);

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@snipesnab 

Consider the following formula:

Set(varRecord,
   If(
       LookUp(yourCollection, 
           "Laptop" in ItemType ||
           "Desktop" in ItemType,
           true
       ),
       "Yes", 
       "No"
   )
)
     

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
snipesnab
Helper II
Helper II

I think I solved the problem with the following code:

 

If(CountRows(Filter(ShoppingCart,"Laptop" in 'ItemType'))>0,
Set(varCMDB,"yes"),Set(varCMDB,"no")
);

PowerRanger
Super User
Super User

@snipesnab have a Look at this Formular - this should do the trick

 

Set(varRekord,If(CountRows(Filter(yourCollection, yourColumn in ["Laptop", "Desktop"]) >0,"Yes","No")))

 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.




​Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item.

If the content was useful in other ways, please consider giving it Thumbs Up.
RandyHayes
Super User
Super User

@snipesnab 

Doing a filter on all the records will impact your performance as you are pulling all the records to then count them.  The LookUp function will return the first record it encounters.  And in the case of the formula I provided, it will return true if it is found and thus you know there is a record as such.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@PowerRanger 
The issue with that formula would be that you are looking to see if the Column is in the words, instead of the other way around - the words in the column.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,870)