cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sasrsc1966
Resolver I
Resolver I

Best practice to avoid repeating yourself

I have a text input field (TextInput1) which is used to filter the data source.

My gallery has this.

Filter(DictAirports,Or(TextInput1.Text in airportName,TextInput1.Text = airportCode ))

Everything works great.

 

I then want to do a count of rows at the bottom of the gallery.

To achieve that I do this...
CountRows(
Filter(
DictAirports,
Or(
TextInput1.Text in airportName,
TextInput1.Text = airportCode
)
)
) & " rows..."

That's really duplicating efforts. If I change my gallery items value I have to remember to change my label for the count.
At what point do you say, let's create a collection instead - but then I don't want my collection to keep refreshing with the onChange action in the text box (if I type abc won't it build a collection for a then realize I've changed it to ab so refresh the collection and then realize it's now abc and reflect the collection again).

What's the best practice? 

1 ACCEPTED SOLUTION

Accepted Solutions
shoog
Super User
Super User

You could determine the rowcount using

CountRows(Gallery1.AllItems)

that will eliminate the need to duplicate your code.

View solution in original post

2 REPLIES 2
shoog
Super User
Super User

You could determine the rowcount using

CountRows(Gallery1.AllItems)

that will eliminate the need to duplicate your code.

Can't believe I didn't know that. Must have missed that 101 class!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,696)