I have a gallery connected to a SharePoint list. I want to be able to click on column headers (buttons) on the list so that the data in that column will be sorted. This is working fine for Text and Date fields but not Choice. Here is how I am achieving the Text/Date fields
Gallery Items:
SortByColumns( *...gallery filtering...* sortCol, If( sortOrder, Ascending, Descending ) )
Sort by Title, on button click:
UpdateContext({sortCol:"Title",sortOrder:!sortOrder})
I tried adding.Value to the sortCol in the line above but that didn't work. Any suggestions?
Solved! Go to Solution.
For this to work, you will need to get the value of the Choice column in your data.
The way to do that is to AddColumns.
SortByColumns( AddColumns(*...gallery filtering...*,
"txtChoice", yourChoiceColumn.Value), sortCol, If( sortOrder, Ascending, Descending ) )
Then for sorting on that choice column:
UpdateContext({sortCol:"txtChoice",sortOrder:!sortOrder})
One thing to keep in mind...If you have any place that you are referring to the Gallery.Selected that is tied to the datasource (i.e. an EditForm that the Item resolves back to Gallery.Selected) then you will need to remove the added column in that property so that it does not conflict with the datasource signature.
I hope that is helpful for you...
For this to work, you will need to get the value of the Choice column in your data.
The way to do that is to AddColumns.
SortByColumns( AddColumns(*...gallery filtering...*,
"txtChoice", yourChoiceColumn.Value), sortCol, If( sortOrder, Ascending, Descending ) )
Then for sorting on that choice column:
UpdateContext({sortCol:"txtChoice",sortOrder:!sortOrder})
One thing to keep in mind...If you have any place that you are referring to the Gallery.Selected that is tied to the datasource (i.e. an EditForm that the Item resolves back to Gallery.Selected) then you will need to remove the added column in that property so that it does not conflict with the datasource signature.
I hope that is helpful for you...
@RandyHayes wrote:For this to work, you will need to get the value of the Choice column in your data.
The way to do that is to AddColumns.
SortByColumns( AddColumns(*...gallery filtering...*,
"txtChoice", yourChoiceColumn.Value), sortCol, If( sortOrder, Ascending, Descending ) )Then for sorting on that choice column:
UpdateContext({sortCol:"txtChoice",sortOrder:!sortOrder})One thing to keep in mind...If you have any place that you are referring to the Gallery.Selected that is tied to the datasource (i.e. an EditForm that the Item resolves back to Gallery.Selected) then you will need to remove the added column in that property so that it does not conflict with the datasource signature.
I hope that is helpful for you...
Hi @RandyHayes
Im a newbie powerapps developers, i need to know where is exactly i put those formula?
And, what is this?
*...gallery filtering...*
Thanks.
In this particular case, @cooper33 was using a Gallery in the App and had an existing filter or other formula for the Items property of the Gallery.
So, the proposed formula was to go into the Items property of the Gallery and the "*...Gallery Filtering...*" was meant to be whatever was currently in that Items property before changing the formula.
I hope that is clear and helps you.
thanks for this post. This gave me the answer I was desperately looking for. Just as a short amendment to Randy's solution, I'd like to propose to remove the additional column right after sorting, so that the problem Randy outlines at the bottom of his/her post won't occur:
DropColumns(
SortByColumns( AddColumns(*...gallery filtering...*,
"txtChoice", yourChoiceColumn.Value), sortCol, If( sortOrder, Ascending, Descending ) ),
"txtChoice"
)
User | Count |
---|---|
142 | |
137 | |
78 | |
73 | |
70 |
User | Count |
---|---|
228 | |
139 | |
78 | |
61 | |
56 |