I'm connecting the power app to a sharepoint list. The app is set up to sort by Title which is then set to descending and ascending.
I'd like to add another sort button (or feature) that will enable to user to sort by ID.
The Browse Screen
OnVisible - ClearCollect(CollMyItems, Filter('Rep 1 Test', 'Created By'.DisplayName=_CurrentUser, User().FullName))
The Gallery
Items - SortByColumns(Filter(CollMyItems, StartsWith("Title", TextSearchBox1.Text)),"Title", If(SortDescending1, Descending, Ascending))
The Sort Button
OnSelect - UpdateContext({SortDescending1: !SortDescending1})
Hey @bmurphy1
The expression used on the OnVisible property is not correct. The correct expression should be:
OnVisible - ClearCollect(CollMyItems, Filter('Rep 1 Test', 'Created By'.DisplayName=_CurrentUser))
Have you tried to create another button for sorting by ID?
What is the issue that you are facing now? If you can share more details we might be able to help you better.
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Hi @bmurphy1 ,
Could you describe more clearly about what you want and where did your app break?
Actually, I think the solution that @yashag2255 posted is right.
The solution means that add another button represent Id. If you click the button, your gallery could sort based on Id and Title at the same time.
He also gave two formulas based on different situations: sort based on id and title, or sort based on id or title.
There has no conflict between the formulas that you listed.
So I need more details.
If you could show me screen shoots, it will be bertter.
Best regards,
That seemed to break everything. Perhaps I need to give you more of what I've written:
App
OnStart - Set(_CurrentUser, User().FullName)
Browse Screen
OnVisible - ClearCollect(CollMyItems, Filter('Rep 1 Test', 'Created By'.DisplayName=_CurrentUser, User().FullName))
Gallery
OnSelect - Set(currentItem, ThisItem)
Items - SortByColumns(Filter(CollMyItems, StartsWith("Title", TextSearchBox1.Text)),"Title", If(SortDescending1, Descending, Ascending))
IconSortUPDown
OnSelect - UpdateContext({SortDescending1: !SortDescending1})
Hi @bmurphy1
Can you try to update the expressions as:
The Browse Screen
OnVisible -
ClearCollect(CollMyItems, Filter('Rep 1 Test', 'Created By'.DisplayName=_CurrentUser))
a) If you want to sort first on Title and then on ID.
The Gallery
Items -
SortByColumns(Filter(CollMyItems, StartsWith("Title", TextSearchBox1.Text)),"Title", If(SortDescending1, Descending, Ascending),"ID", If(SortById1, Descending, Ascending))
Button to sort by ID
OnSelect -
UpdateContext({SortById1: !SortById1})
b) If you want to toggle sort between Title and ID.
Items -
If(SortBy = "ID",SortByColumns(Filter(CollMyItems, StartsWith("Title", TextSearchBox1.Text)),"ID",If(SortById1, Descending, Ascending)), SortByColumns(Filter(CollMyItems, StartsWith("Title", TextSearchBox1.Text)),"Title",If(SortDescending1, Descending, Ascending)))
Button to sort by ID
OnSelect -
UpdateContext({SortBy:"ID",SortById1: !SortById1})
The Sort Button
OnSelect -
UpdateContext({SortBy:"Title",SortDescending1: !SortDescending1})
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
WarrenBelz
146,731
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional