cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RobRoy
Helper III
Helper III

CountIF with contains or "In"

Hello,

 

I am trying to count the results of a search using the following:

 

CountIf(Events, Event = TextSearchBox1_1.Text)

But the results only count if the search words are an exact match for all the words in the Event field of the Events datasource (SharePoint list). How can I edit this code to count all the results when only one or two keywords match the entire Event? I already have the search working since I see results when only one keyword matches.

 

Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

You can use the Find function to check whether the event contains the word in the text search box:

CountIf(Events, Find(TextSearchBox1_1.Text, Event) > 0)

That will give you the count of the Events records where the Event column contains the text in the search box.

View solution in original post

You can use the Lower (or Upper) function on both sides to make the comparison case-insensitive.

CountIf(Events, Find(Lower(TextSearchBox1_1.Text), Lower(Event)) > 0)

Notice that currently those functions (Lower/Upper) are not delegatable to the server (Sharepoint, in your case) yet, which means that they will only be applied in a local copy of the list. If your list is small (less than 500 elements, IIRC), then it will not be a problem, but if it's larger than that, then this workaround will not work at this moment.

View solution in original post

4 REPLIES 4
CarlosFigueira
Power Apps
Power Apps

You can use the Find function to check whether the event contains the word in the text search box:

CountIf(Events, Find(TextSearchBox1_1.Text, Event) > 0)

That will give you the count of the Events records where the Event column contains the text in the search box.

View solution in original post

That works, thank you! Although I notice it is case-sensitive. Any way to make it case-insensitive?

You can use the Lower (or Upper) function on both sides to make the comparison case-insensitive.

CountIf(Events, Find(Lower(TextSearchBox1_1.Text), Lower(Event)) > 0)

Notice that currently those functions (Lower/Upper) are not delegatable to the server (Sharepoint, in your case) yet, which means that they will only be applied in a local copy of the list. If your list is small (less than 500 elements, IIRC), then it will not be a problem, but if it's larger than that, then this workaround will not work at this moment.

View solution in original post

Awesome, thanks again.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (47,331)