web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

Function ordering

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all,

I'm i'm a few months into my PowerApps knowledge adventure, and I continue to struggle with one concept - how to determine the order of functions.

For example, right now I have a gallery with items:

SortByColumns(

     GroupBy(

            Filter(

            Captains,

            Country=CountrySelected),

    "State","States"),

"State",Ascending)

 

My datasource is a list of people with their respective city, state, and country.  I have a gallery that's showing the countries, which takes you to a gallery that shows the states/provinces in that country, that takes you to a gallery with the cities in that state/provice, and finally a gallery with the people located there.  

I have a TextBoxSearch3.Text I want to add to the above which is the gallery that shows all of the states.  How do I decide where to put it - before/after my GroupBy, before/after my Filter, and i'm pretty positive it doesn't go before, but what about after SortByColumns?  I think I understand the general idea that it's in the order you want things to happen.  The search box doesn't really depend on the groupby, but it does need to only search the data after what has been filtered.  I feel like i'm answering my own question - work from the inside out in order of events, but are there any times where the ordering doesn't really matter also?  

Thx in advance!

Categories:
  • Verified answer
    Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    Within an individual function it always evaluates from the innermost set of parentheses out.  In your example the Filter will Filter the records in the data source first, then they will be States and then the grouped results will be sorted in ascending order. For your text box you can either add another level by adding Search() to surround the Filter or by adding the textbox to your Filter condition.

  • russrimm Profile Picture
    Microsoft Employee on at

    Thanks, so this seems to confirm my suspicion that in many cases there are multiple options to accomplish the same end goal and in some cases it just doesn't matter? 

    I think I got it!

    SortByColumns(GroupBy(Search(Filter(Captains, Country=CountrySelected),TextSearchBox3.Text, "State"),"State","States"),"State",Ascending)

  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    Yes, especially when nesting functions there are often many different wasy to do it.  This is often important when dealing with delegation.  YOu can sometimes use a delegable filter to get a datasource below the 500 limit and then use a non-delegable function on the result.  If you nest them the other way around it doesn't work.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard