cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
russrimm
Level: Powered On

Function ordering

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Function ordering

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

3 REPLIES 3
Dual Super User
Dual Super User

Re: Function ordering

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

russrimm
Level: Powered On

Re: Function ordering

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)

Dual Super User
Dual Super User

Re: Function ordering

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,168)