Using IsBlank with Gallery Items to hide empty records

This post details about the use of Isblank function in power apps.

Scenario : A power apps user enters details such as name, phone and comments and adds them to a collection say “ContactInfo”.
The items from the collection is then displayed in the gallery.

Lets take a look at the below screen displaying records in a gallery where title is set to name and subtitle is set to phone.

galleryItemswithoutIsblank

Problem : The user can leave the name field as empty resulting the collection to not have any name, hence the gallery displays records with out name. This is because the items property of the gallery is simply set to the collection “ContactInfo”

Itemsinfo1

 

Requirement : The gallery should be filtered such that it displays only items that has name

Solution : Filter + IsBlank

The IsBlank function tests for a blank value or an empty string, whose result can be used to filter the items property of the gallery, in our case we need to check if there is a name in the collection”ContactInfo”, if yes then display the collection items in the gallery, otherwise do not display.

Notice after the Items property is set with the below function  the gallery will only display records which has a value for the name.
Filter(ContactInfo, !IsBlank(Name));

ItemsIsblank

 

 

 

Thanks,
Shayan