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 Platform Community / Forums / Power Apps / SORT WITH MULTIPLE FIL...
Power Apps
Answered

SORT WITH MULTIPLE FILTERS

(0) ShareShare
ReportReport
Posted on by

Hi, I wanna sort by the newest item to the oldest on this formula with multiple filters...

 

If(
 varUser.Email = "erica.dias@arapyauinstituto.onmicrosoft.com";
 Sort(Filter(
 Despesas;
 Solicitante = TextInput1.Text || 'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID
 );Descending);
 Sort(Filter(
 Despesas;
 'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID;
 CreatorEmail = varUser.Email
 );Descending
)

 

And I got a delegation warning...

Categories:
  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @Gorilla_8,

    To answer the question you have asked, apart from missing a closing bracket on what you posted, Choice or Lookup columns are not Delegable.
    'Status de pagamento'.Value

    If(
     varUser.Email = "erica.dias@arapyauinstituto.onmicrosoft.com";
     Sort(
     Filter(
     Despesas;
     Solicitante = TextInput1.Text || 
     'Status de pagamento'.Value = DropDown1_2.Selected.Value || 
     ID = DropDown1_1.Selected.ID
     );
     ID,
     Descending
     );
     Sort(
     Filter(
     Despesas;
     'Status de pagamento'.Value = DropDown1_2.Selected.Value || 
     ID = DropDown1_1.Selected.ID;
     CreatorEmail = varUser.Email
     );
     ID;
     );Descending
    )

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • Gorilla_8 Profile Picture
    on at

    Hi @WarrenBelz !

    thanks for the reply, so how I can sort this gallery or I cant do it?

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @Gorilla_8 ,

    You can sort it as posted by ID to get the newest records on top - it is the Filter that is the issue (so it will only give you the first 2000 records to filter)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Gorilla_8 ,

    Could you please share a bit more about the Delegation issue in your formula?

     

    Based on the Sort formula that you mentioned above, I think there is something wrong with it. The syntax formula of the Sort function as below:

    Sort( Table, Formula [, SortOrder ] )

    within your Sort formula, you have missed the second argument -- which column you want to sort by.

     

    Please modify your formula as below:

    If(
     varUser.Email = "erica.dias@arapyauinstituto.onmicrosoft.com";
     Sort(
     Filter(
     Despesas;
     Solicitante = TextInput1.Text || 'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID
     );
     Created; // Type the Created column here
     Descending
     );
     Sort(
     Filter(
     Despesas;
     'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID;
     CreatorEmail = varUser.Email
     );
     Created; // Type the Created column here
     Descending
     )
    )

     

    Please consider take a try with above solution, them check if the issue is solved.

     

    Best regards,

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @Gorilla_8 ,

    I will leave you with @v-xida-msft as they have investigated further

  • Gorilla_8 Profile Picture
    on at

    Hi @WarrenBelz and @v-xida-msft ! Thanks for the reply!

    @WarrenBelz Thanks for the help again!

    So, @v-xida-msft , I know the formula about the "sort" is SortTableFormula [; SortOrder ])

    But If I try put this code:

     

    If(
     varUser.Email = "admin@user.com";
     Sort(Filter(
     Despesas;
     Solicitante = TextInput1.Text || 'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID
     );Ascending);

     

    I got a delegation warning, like the @WarrenBelz told me about it!

     

    And If I try with a formula:

     

    If(
     varUser.Email = "user@admin.com";
     Sort(
     Despesas;
     Filter(
     Despesas;
     Solicitante = TextInput1.Text || 'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID
     );
     Ascending
     );
     Sort(Despesas;
     Filter(
     Despesas;
     'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID;
     CreatorEmail = varUser.Email
     );Ascending)
    )

     

    I don't understand why got an error

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Gorilla_8 ,

    Based on the formula that you mentioned, I think you have some misunderstanding with the Sort formula. The second argument of the Sort function is required to provide a formula which would be calculated into a single one value, but the Filter formula you provided returned is a Table value.

     

    Normally, the second argument of the Sort function is used to reference a column from your data source as Sort column. So please modify your formula as below:

    If(
     varUser.Email = "erica.dias@arapyauinstituto.onmicrosoft.com";
     Sort(
     Filter(
     Despesas;
     Solicitante = TextInput1.Text || 'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID
     );
     Created; // Reference column name from your Despesas data source here
     Descending
     );
     Sort(
     Filter(
     Despesas;
     'Status de pagamento'.Value = DropDown1_2.Selected.Value || ID = DropDown1_1.Selected.ID;
     CreatorEmail = varUser.Email
     );
     Created; // Reference column name from your Despesas data source here
     Descending
     )
    )

    Note: The second argument of the Sort function is required to provide a formula which would be calculated into a single value rather than table value.

     

    For your first formula you mentioned, you have missed the second argument in your Sort function. For your second formula, you have some misunderstanding on which value should be typed as the second argument in the Sort function. Hope above explanation could help in your scenario.

     

    Please check the sample of Sort function in the following article for more details:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-sort#examples

     

    Best regards,

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 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard