PowerApps Galleries Part 2

Use functions in a gallery

In a previous post, a gallery was customized by adding a new label. The label displays the data from a field in the data source. Emphasis was added to the label by changing some of the label’s color properties.

Unfortunately, there isn’t always data in the field for the label, as shown below. The label appears as empty rectangle.

Use a function, to resolve this issue while adding useful information.

Select the label in the Tree View.

In this example, the Text property displays the following text:
ThisItem.’Claimed By’

In the example, Claimed By is the name of the data field in the data source.

Let’s replace that text with an If statement:
If(IsBlank(‘Claimed By’),”Unclaimed”,ThisItem.’Claimed By’)

This statement checks to see if the Claimed By field is blank for the given record. If it is, then the word Unclaimed is displayed. If the field is not blank, then whatever is in the field is displayed.

Gallery with a function to dynamically change label text

This function makes the gallery more useful. We can now see that an incident is not claimed. Unfortunately, the label is the same color even if the incident is not claimed.

We can draw more attention to these incidents by changing the color of the label for these incidents.

To accomplish this, select the label in the Tree View.

View the Fill property for the label. In this example, the Fill property for the label displays the following RGBA color:
RGBA(54, 176, 75, 1)

Let’s replace the RGBA color with an If statement:
If(IsBlank(‘Claimed By’),RGBA(168,0,0,1),RGBA(54, 176, 75, 1))

This statement checks to see if the Claimed By field is blank for the given record. If it is, then the label fill is red. If the field is not blank, then the label is green.

Gallery with a function to dynamically change label fill

These two functions makes the gallery much more powerful and useful. At a glance, we can see that an incident is not claimed.