cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Display label if gallery filter returns no results

I need to display a label with a message "Unknown.  Contact Support for assistance" if a gallery filter doesn't display any results.

 

I have a data source (SharePoint List) that lists address and phone number information. 

I have a TextInput box for my search box.  A "Search" button which converts the contents of the TextInput into a variable.  And a gallery which displays the contents of the datasource if it exists.

 

Button - Onselect - Set(varSite, TextInput1.Text)
Gallery - Items -  If(varSite = "", Blank(),
                                      Filter('BT-Sites', varSite in Postcode || varSite in Title))

 

I also have a reset button that clears all entries

 

Reset button - Onselect - Reset(TextInput1);
                                                         Set(varSite, "")

 

I can't work out how to display a label if the search run doesn't display any results in the gallery.  I currently have the label set to Visible - If(IsBlank('BT-Gallery'), "true", "false")  but this means it displays if the gallery is blank and obviously the gallery is always blank when the app first launches prior to entering anything into the textinput box so need to get around this.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Advocate V
Advocate V

Re: Display label if gallery filter returns no results

Ok well another, possible cleaner, alternative would be to create a new variable that controls the visibility of your label.

 

Keep everything as you had it in your original post and then add

 

Screen - OnVisible - UpdateContext({varLabelVis : 0 })

 

Button - OnSelect - UpdateContext({varLabelVis: 1 }) ; Then everything else as you have above

 

Visible - If(IsBlank('BT-Gallery') AND varLabelVis = 1, "true", "false")

 

That means then the button must be pressed at least once to make your label appear.

View solution in original post

Highlighted
Advocate V
Advocate V

Re: Display label if gallery filter returns no results

I'm a little confused to be honest. You want the label to show only if both gallerys are blank?

 

Try

 

If(IsBlank(BTgallery) AND IsBlank(MTgallery),If(varLabelViz = 1,true,false),false)

That should return false if either gallery is not blank, and true only if both gallerys are blank and the variable = 1

View solution in original post

5 REPLIES 5
Highlighted
Advocate V
Advocate V

Re: Display label if gallery filter returns no results

Could you try set your gallery to show every item in the list when the screen loads, then after searching the textbox you could display the label. You might nee two lists to do this. lLets say PreSearchBT-Items and PostSearchBT-Items.

 

So for example you could have...

 

Screen - On Visible - ClearCollect(PreSearchBT-Items,SPdatasource) ; ClearCollect(PostSearchBT-Items,PreSearchBT-Items)

 

This would initially mean pre and post lists are identical.

 

Then Gallery - Items - (PostSearchBT-Items)

 

Button - OnSelect - ClearCollect(PostSearchBT-Items,Filter(PreSearchBT-Items,TextInput etc.))

 

Label - Visible - If(CountRows(PostSearchBT-Items)>0,false,true)

Highlighted
Helper I
Helper I

Re: Display label if gallery filter returns no results

Thanks for this.  I see what you're trying to achieve here but it doesn't exactly work.  The purpose of the gallery being blank on screen visible is so the team using the app don't see any data other than what is returned via their search.  I should also mention that I tried to simplify the request by saying there is just 1 gallery but actually there are 2 stacked on top of each other.  Each gallery contains data from different network providers and the search box searches both galleries and depending on which list it appears in brings back the site details along with a logo of the network provider.  That parts quite simple and working, but I still need a method of displaying a message if the search number used doesn't appear on either sharepoint list therefor the gallery would be blank.

Hope this makes sense.

Highlighted
Advocate V
Advocate V

Re: Display label if gallery filter returns no results

Ok well another, possible cleaner, alternative would be to create a new variable that controls the visibility of your label.

 

Keep everything as you had it in your original post and then add

 

Screen - OnVisible - UpdateContext({varLabelVis : 0 })

 

Button - OnSelect - UpdateContext({varLabelVis: 1 }) ; Then everything else as you have above

 

Visible - If(IsBlank('BT-Gallery') AND varLabelVis = 1, "true", "false")

 

That means then the button must be pressed at least once to make your label appear.

View solution in original post

Highlighted
Helper I
Helper I

Re: Display label if gallery filter returns no results

I spoke too soon.  It works when searching for anything on the BT gallery and displays the label if it doesn't exist.  However if I search for anything on the other gallery that does exist it displays the site information as well as the label.  I tried this and variations of it but it didn't work.

If(IsBlank('BT-Gallery' || 'Maintel-Gallery') And varLabelVis = 1, "true", "false")
Highlighted
Advocate V
Advocate V

Re: Display label if gallery filter returns no results

I'm a little confused to be honest. You want the label to show only if both gallerys are blank?

 

Try

 

If(IsBlank(BTgallery) AND IsBlank(MTgallery),If(varLabelViz = 1,true,false),false)

That should return false if either gallery is not blank, and true only if both gallerys are blank and the variable = 1

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (11,102)