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

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
seanbrogan
Responsive Resident
Responsive Resident

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

seanbrogan
Responsive Resident
Responsive Resident

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
seanbrogan
Responsive Resident
Responsive Resident

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)

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.

seanbrogan
Responsive Resident
Responsive Resident

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.

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")
seanbrogan
Responsive Resident
Responsive Resident

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

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (5,204)