PowerApps Template Gallery List Default Sort Order

%3CLINGO-SUB%20id%3D%22lingo-sub-127707%22%20slang%3D%22en-US%22%3EPowerApps%20Template%20Gallery%20List%20Default%20Sort%20Order%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-127707%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Everyone...%20Im%20hoping%20this%20is%20a%20very%20easily%20solution.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBuilding%20a%20Power%20App%20and%20i%20have%20a%26nbsp%3BTemplate%20Gallery%20Display%20List%20on%20a%20screen%20which%20defaults%20to%20show%20the%20Created%20as%20Ascending.%20Is%20it%20possible%20to%20have%20the%20default%20view%20to%20be%20descending%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20added%20a%20sort%20button%20and%20works%20fine%20but%20i%20need%20to%20know%20if%20you%20can%20have%20the%20default%20sort%20to%20be%20descending%20based%20upon%20the%20created%20date%20without%20the%20sort%20button.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20you%20can%20see%20from%20image%20below%20its%20just%20straight%20OTB%20and%20nothing%20crazy.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F24128iEADCABA0914794A0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Sort.PNG%22%20title%3D%22Sort.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-127707%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerApps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-415501%22%20slang%3D%22en-US%22%3ERe%3A%20PowerApps%20Template%20Gallery%20List%20Default%20Sort%20Order%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-415501%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F314804%22%20target%3D%22_blank%22%3E%40mctriv%3C%2FA%3E%26nbsp%3Bbeen%20a%20couple%20years%20since%20this%20post.%20I%20have%20learned%20a%20few%20ways%20of%20doing%20this%20one.%20The%20best%20way%20to%20learn%20this%20is%20actually%20using%20one%20of%20the%20OTB%20templates%20in%20PowerApps%20as%20they%20have%20the%20sort%20order%20functionality%20already%20built%2C%20you%20just%20set%20the%20default%20to%20ascending%20or%20descending%20and%20then%20hide%20the%20button%20to%20change%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBelow%20are%20the%20Gallery%20formulas%20you%20could%20use%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ESortByColumns%3C%2FSTRONG%3E(Filter('ICT%20Service%20Requests'%2C%20StartsWith(Title%2C%20TextSearchBox1.Text))%3CSTRONG%3E%2C%20%22Created%22%2C%20If(SortDescending1%2C%20Descending%2C%20Ascending))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ESortByColumns%3C%2FSTRONG%3E(Filter('ICT%20Service%20Requests'%2C%20StartsWith(Title%2C%20TextSearchBox1.Text))%3CSTRONG%3E%2C%20%22Created%22%2C%20If(SortDescending1%2C%20Ascending%2C%20Descending))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20above%20is%20OTB%20for%20the%20Items%20section%20of%20the%20Gallery%20which%20usually%20is%20connected%20to%20a%20button%20for%20sort%20however%20if%20you%20just%20change%20the%20SortByColumns%20to%20be%20the%20other%20way%20around%20it%20works%20great.%20The%20default%20cannot%20be%20changed%20without%20using%20the%20SortByColumns%20option.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20will%20still%20need%20the%20button%20for%20the%20sort%20order%20as%20far%20as%20i%20have%20been%20able%20to%20work%20out%20which%20needs%20the%20onselect%20to%20be%20something%20like%20this.%3C%2FP%3E%3CP%3EUpdateContext(%7BSortDescending1%3A%20!SortDescending1%7D)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20then%20just%20set%20the%20button%20to%20not%20be%20visible%20once%20you%20have%20the%20default%20to%20how%20you%20need%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20may%20be%20a%20much%20more%20simple%20way%20of%20doing%20this%20though%2C%20but%20this%20is%20the%20quickest%20way%20i%20have%20found.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-400695%22%20slang%3D%22en-US%22%3ERe%3A%20PowerApps%20Template%20Gallery%20List%20Default%20Sort%20Order%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-400695%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F86351%22%20target%3D%22_blank%22%3E%40Stuart%20Anderson%3C%2FA%3E%26nbsp%3BI%20have%20exactly%20the%20same%20problem%2C%20I've%20been%20applying%20SortByColumns%20in%20various%20ways%20but%20can't%20get%20it%20to%20work%2C%20if%20I%20have%20any%20success%2C%20or%20you%20do%2C%20please%20let%20me%20know!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-415675%22%20slang%3D%22en-US%22%3ERe%3A%20PowerApps%20Template%20Gallery%20List%20Default%20Sort%20Order%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-415675%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F86351%22%20target%3D%22_blank%22%3E%40Stuart%20Anderson%3C%2FA%3E%26nbsp%3BThank%20you%2C%20I'll%20give%20them%20a%20whirl.%20much%20appreciated.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi Everyone... Im hoping this is a very easily solution.

 

Building a Power App and i have a Template Gallery Display List on a screen which defaults to show the Created as Ascending. Is it possible to have the default view to be descending?

 

I have added a sort button and works fine but i need to know if you can have the default sort to be descending based upon the created date without the sort button.

 

As you can see from image below its just straight OTB and nothing crazy.

Sort.PNG

3 Replies
Highlighted

@Stuart Anderson I have exactly the same problem, I've been applying SortByColumns in various ways but can't get it to work, if I have any success, or you do, please let me know!

Highlighted

@mctriv been a couple years since this post. I have learned a few ways of doing this one. The best way to learn this is actually using one of the OTB templates in PowerApps as they have the sort order functionality already built, you just set the default to ascending or descending and then hide the button to change it.

 

Below are the Gallery formulas you could use;

SortByColumns(Filter('ICT Service Requests', StartsWith(Title, TextSearchBox1.Text)), "Created", If(SortDescending1, Descending, Ascending))

 

SortByColumns(Filter('ICT Service Requests', StartsWith(Title, TextSearchBox1.Text)), "Created", If(SortDescending1, Ascending, Descending))

 

The above is OTB for the Items section of the Gallery which usually is connected to a button for sort however if you just change the SortByColumns to be the other way around it works great. The default cannot be changed without using the SortByColumns option.

 

You will still need the button for the sort order as far as i have been able to work out which needs the onselect to be something like this.

UpdateContext({SortDescending1: !SortDescending1})

 

But then just set the button to not be visible once you have the default to how you need it.

 

There may be a much more simple way of doing this though, but this is the quickest way i have found.

Highlighted

@Stuart Anderson Thank you, I'll give them a whirl. much appreciated.