How to perform Contains() search in PowerApps Canvas Apps

Canvas are a delight to work with, specially with so many in-built functions and operators which makes our life a whole lot easier. However developers and consultants from past programming background are accustomed to some functions which surprisingly may be missing from Canvas apps. And contains() is one such function.

What are the common scenarios where contains() function is required?

  • You want to search for a specific text inside control.
  • You want to filter datasets if a column contains specific text
  • You want to filter datasets if a column contains a specific value within a collection.

Now the real question. Is it really missing or there exists an alternate function to perform the same operation? In-fact there exists the in and exactin operators which does the same job of contains search.

Let’s explore how we can use the in operator.

The following code is to check if the specific text is present in the whole string.

contains function in canvas apps

The above code is pretty simple. Let’s dive into something more complex. The following code filters the accounts table in CDS to match records where Account Number field contains the text “OPS”

contains function in canvas apps

Now time to make it little more complex. The following code filters the accounts table in CDS to match records where ‘Account Number’ field has a matching value in the ‘Code‘ property of a local collection – ListItems.

contains function in canvas apps

That’s pretty much for in. You can obviously make out now how to utilize for your own scenarios. Now the next is the exactin operator. Functionality wise, it behaves exactly similar to in with the only difference that exactin is a case sensitive search.

If we take the previous example, the expression will return false instead of true. Even though “C” is present in America but because we have used exactin, the comparison is now case sensitive.

contains function in canvas apps

Hope this helped!

You may also like the below posts!

Debajit Dutta
Business Solutions MVP


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading