cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

SORT WITH MULTIPLE FILTERS

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...

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Highlighted
Super User III
Super User III

@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.

 

Highlighted

Hi @WarrenBelz !

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

Highlighted

@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.

Highlighted
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

@Gorilla_8 ,

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

Highlighted

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

Highlighted

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,821)