cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenGillard
Level: Powered On

Gallery to only showing results that match the search

Hi,

I currently have a search Function that works well with my data. 

 

However i would like to add another function if possible where the gallery is empty until the search criteria is met. As currently it shows all results to start with and then filters the list down when you begin searching.

 

I currently have this:

 

SortByColumns(Search(AllResources,SearchMain.Text,"KeyWords","Title","Description"),"{Name}",Ascending)

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
OneThing
Level 8

Re: Gallery to only showing results that match the search

Hi @BenGillard

 

You can use the IsBlank Function to deal with this.

Basically:

If(!IsBlank(TextSearchBox.Text),Query)

 This will check if the text searchbox is not blank, Search with the results if it has a value, else it will do nothing.

 

Full code should be something along these lines. 

If(!IsBlank(SearchMain.Text), 
 SortByColumns(Search(AllResources,SearchMain.Text,"KeyWords","Title","Description"),"{Name}",Ascending)
)

 

Thanks,
Nicky

 

6 REPLIES 6
Highlighted
OneThing
Level 8

Re: Gallery to only showing results that match the search

Hi @BenGillard

 

You can use the IsBlank Function to deal with this.

Basically:

If(!IsBlank(TextSearchBox.Text),Query)

 This will check if the text searchbox is not blank, Search with the results if it has a value, else it will do nothing.

 

Full code should be something along these lines. 

If(!IsBlank(SearchMain.Text), 
 SortByColumns(Search(AllResources,SearchMain.Text,"KeyWords","Title","Description"),"{Name}",Ascending)
)

 

Thanks,
Nicky

 

BenGillard
Level: Powered On

Re: Gallery to only showing results that match the search

Just for my own sanity! When i copy and paste yours it works great so thankyou very much.

 

However when i tried to edit mine as shown below it doesnt work:

If(!IsBlank(SearchMain.Text),SortByColumns(Search(AllResources,SearchMain.Text,"KeyWords","Title","Description","{Name}",Ascending)

 

If you could tell me what i am doing wrong in the above so i know for next time that would be great.

 

Also what does the function of the ! do infront of IsBlank as thta doesnt seem to be part of the IsBlank forumula.

 

Thanks in advance

 

 

 

Sofie_D
Level 8

Re: Gallery to only showing results that match the search

the '!' means 'Not'. So '!IsBlank(SearchMain.Text)' returns true if searchmain.text is not blank.

 

About your formula, you need another ')' at the end.

BenGillard
Level: Powered On

Re: Gallery to only showing results that match the search

Sorry, I discovered i was missing a ) after "Description".

 

If(!IsBlank(SearchMain.Text),SortByColumns(Search(AllResources,SearchMain.Text,"KeyWords","Title","Description"),"{Name}",Ascending)

 

Thanks ofr your help. If anyone could let me know about the ! infront of IsBlank that would be greatly appreicate.

 

Apologies i am still very new to this Smiley Happy

 

 

BenGillard
Level: Powered On

Re: Gallery to only showing results that match the search

Great thanks

OneThing
Level 8

Re: Gallery to only showing results that match the search

Hi @BenGillard,

 

@Sofie_D mentioned before that ! is a quick way to do the Not function, but you might have missed it.

 

You can also do it this way if you prefer:

If(Not(IsBlank(TextSearchBox.Text)),Query)

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-logicals contains more information on Not, And and Or

 

Thanks,
Nicky

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 53 members 4,690 guests
Please welcome our newest community members: