web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / If Collection column C...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 69

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?

 

 

 

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @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.

  • Verified answer
    snipesnab Profile Picture
    69 on at

    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 Profile Picture
    3,458 Super User 2024 Season 1 on at

    @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.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @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.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard