cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
e351445
Frequent Visitor

Filter and Sort PowerApps

Hi! 

I'm new in the PowerApps world... and I'm having some difficulties with sort and filter function. 

I want to obtain the maxium value from the field "Ordem" (in a textinput), from a table, where the field "UO" it's equal to the value from a dropdown table. 

I tried the following expression: 

Spoiler
Last(Sort(Filter(tblNewOportunidades,UO=DataCardValue.Selected),Ordem,Ascending).Ordem

Can someone help me to find where is my mistake? 

1 ACCEPTED SOLUTION

Accepted Solutions

@e351445 

Wich kind of data source you are connecting?

Please try this workaround, using Gallery.AllItems to avoid delegation error.

1. Add a gallery to display all sorted and filtered records of tblNewOportunidades, set Items property of gallery as below:

Sort(Filter(tblNewOportunidades,UO=DataCardValue.Selected),Ordem,Ascending)

2. set Default property of TextInput box:

Last(Gallery.AllItems).Ordem

Note: if there is no need to display the gallery, just set the visible property to false.

delegation threshold is 4delegation threshold is 4

Sik

 

View solution in original post

7 REPLIES 7
mdevaney
Super User III
Super User III

@e351445 

You can find the maximum value by using the MAX function on a Table

 

Max(
    Filter(tblNewOportunidades,UO=DataCardValue.Selected),
    Ordem
)

 

You might also want to try this slightly different code if the first solution doesn't work

Max(
    Filter(tblNewOportunidades,UO=DataCardValue.Selected.Value),
    Ordem
)

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

v-siky-msft
Community Support
Community Support

@e351445 

Is there any error message on the formula? could you show the screenshots?

It seems you are missing a ")", please try this:

Last(Sort(Filter(tblNewOportunidades,UO=DataCardValue.Selected),Ordem,Ascending)).Ordem

Sik

e351445
Frequent Visitor

Hi! 

Thank you so much for your reply! 

When I tried your solution, I got this warning: 

"Delegation warning. The highlighted part of this formula might not work correctly on large data sets. The "Max" operation is not supported by this connector. 
This rule creates a circular reference between proprieties, which is not allowed. A property cannot reference itself or ther properties affected by its value."

I'm still working with a database that only has like 5/10 records. 

Hi! 

Thank you so much for your reply! 

I tried your solution, I a got this warning: 

"Delegation warning. The "Sort" part of this formula might not work correctly on large data sets."

I'm working with a database that only has like 5/10 records. 

@e351445 

Wich kind of data source you are connecting?

Please try this workaround, using Gallery.AllItems to avoid delegation error.

1. Add a gallery to display all sorted and filtered records of tblNewOportunidades, set Items property of gallery as below:

Sort(Filter(tblNewOportunidades,UO=DataCardValue.Selected),Ordem,Ascending)

2. set Default property of TextInput box:

Last(Gallery.AllItems).Ordem

Note: if there is no need to display the gallery, just set the visible property to false.

delegation threshold is 4delegation threshold is 4

Sik

 

View solution in original post

Hi, @v-siky-msft!

This solution worked really well!

Thank you! 😃

@e351445
The delegation warning can be safely ignored if your list has less than 2,000 items

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,529)