App Display
Sort_Button_Code
BrowseGallery_CodeHello,
I am trying to Sort my records by Serial number like 1,2,3... in ascending and Descending order ( Last to 1st) record.
But I am facing a little problem there, It's sorting in ascending and descending order but not what I wanted.
Problem: 1,10,11,12... 2,20,23... (sorting in this format).
Attaching Screenshots for your reference.
Kindly Help
Solved! Go to Solution.
If changing the serial number field to an integer as @mdevaney suggests isn't feasible you might also try using Sort() with a Value() function for the expression. That would convert the alpha serial number to a number as part of the sort. The one problem is that the value() expression isn't delegable so it won't work with a large number of records.
Sort(DataSource,Value('Serial Number'))
I'm tied up with something right now, but I could join a session in about 30 minutes Noon Eastern Time (USA).
Your serial number is likely a text value. A text value sorts in the order:
1, 10, 11, 12, 2, 20, 23
Instead, you should change your serial number to a number value in the data source. The result will be:
1, 2, 10, 11, 12, 20, 23
---
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."
If changing the serial number field to an integer as @mdevaney suggests isn't feasible you might also try using Sort() with a Value() function for the expression. That would convert the alpha serial number to a number as part of the sort. The one problem is that the value() expression isn't delegable so it won't work with a large number of records.
Sort(DataSource,Value('Serial Number'))
Dear @mdevaney ,
I have tried everything, changed the serial number to Nmber Format, but still I can't get the solution.
Please help
Sort(DataSource,Value('Serial Number')),if(SortDescending1, Descending, Ascending))
???
Do, I have to write this code, in order to use the Sort Button?
Dear @Pstork1 ,
It is sorted but, the Sort Button is not working and its not performing Ascending and Descending Sort..
Kindly Help
Yes, you have to put code in the OnSelect for the Sort button. Also, you need to make sure that the gallery is sorting on numeric values and not string values. Numbers will sort differently than strings. The correct code should be:
Sort(DataSource,Value('Serial Number'),if(SortDescending1, Descending, Ascending));Set(SortDescending1, not(SortDescending1))
You had an extra closing Parentheses. You'll also need something to set SortDescending1 when you flip it.
Dear @Pstork1 ,
I am sorry, it's still not working
Sort('P.A.A.S. ',Value("S_x002e__x0020__x0023_"), If(SortDescending1, Descending, Ascending));
Set(SortDescending1, Not(SortDescending1))
It says you can't use Not in the APP.
Help
@mdevaney Yes, I have used in the OnSelect Property, but still no progress.
SortByColumns(Search('P.A.A.S. ', TextSearchBox1.Text,"S_x002e__x0020__x0023_"),
"S_x002e__x0020__x0023_", If(SortDescending1, Descending, Ascending))
Currently using this code, but the sorting is like 1,10,100,101,11,12... which is wrong, although I have changed the TextSearchBox Format into "Number".
Kindly Help
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
193 | |
53 | |
51 | |
37 | |
37 |
User | Count |
---|---|
283 | |
94 | |
85 | |
77 | |
77 |