Hi all,
I have a gallery connected to a database table with the following columns:
ChildName Center Date State
And I have implemented SortByColumns() in the gallery which sorts on search results (if any)
SortByColumns(Search('[dbo].[tblTardyStatus]_1', TextSearchBox1.Text, "ChildName", "Center","Date","State"),"State", ["New", "Absent", "Absent unexcused", "Late", "Late unexcused", "On-time"])
It sorts a filtered result based on the Search() parameters (text matching any of the 4 columns) and then sorts it by the "State" column with a custom order which is
["New", "Absent", "Absent unexcused", "Late", "Late unexcused", "On-time"]
The issue I'm having is then sorting the results in alphabetical order according to the ChildName column. I have by adding two new arguments to the SortByColumns like displayed on the sort function page for powerapps
SortByColumns(Search('[dbo].[tblTardyStatus]_1', TextSearchBox1.Text, "ChildName", "Center","Date","State"),"State", ["New", "Absent", "Absent unexcused", "Late", "Late unexcused", "On-time"], "ChildName", Ascending)
The issue is that it returns the error "SortByColumns has some invalid arguments"
Thanks for any help
Hi @ChrisC,
The syntax for the SortByColumns is as below:
First usage:
SortByColumns( Table, ColumnName1 [, SortOrder1, ColumnName2, SortOrder2, ... ] )
Second usage:
SortByColumns( Table, ColumnName, SortOrderTable )
Per your formula, you are trying to combine those two usage into one, which is not supported.
To workaround this, take a try to add a nested SortByColumns funtion.
Formula should be:
SortByColumns( SortByColumns( Search('[dbo].[tblTardyStatus]_1', TextSearchBox1.Text, "ChildName", "Center","Date","State"), "State", ["New", "Absent", "Absent unexcused", "Late", "Late unexcused", "On-time"]),
"ChildName", Ascending)
Regards,
Michael
Hi @v-micsh-msft,
It doesn't seem to be sorting by childname still but I cannot see why your solution wouldn't work..
I also tried reversing the nest order to see if that would do it but unfortunately not. Thank you for the insight though, I will try and come up with a solution based on this
I'm seeing the same results as @ChrisC here- A Custom Sort + Sort by Alpha does not seem to be working. Does anyone know how to do a custom sort where a group of columns are presented first, then the remaining columns sorted alphabetical in ascending order?
Example:
SortByColumns(
SortByColumns(
colData,
"CHAR_NAME",
[
"THING1",
"OTHERTHING1",
"THING2",
"OTHERTHING2",
"ETC"
]
),
"CHAR_NAME",
Ascending
)
Thanks
Hi @ericonline ,
Try this
Sort(
SortByColumns(
colData,
"CHAR_NAME",
[
"THING1",
"OTHERTHING1",
"THING2",
"OTHERTHING2",
"ETC"
]
),
CHAR_NAME,
Ascending
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @WarrenBelz . Thanks for the idea. This sorting just eliminates the custom sort (in the square brackets) and puts the whole list in alpha.
I'm looking for custom sort up top, then alpha after.
Hi @v-micsh-msft . Thanks for the idea. This results in losing the custom sort (everything in the square brackets). The list is sorted by alphanumeric only.
I need the custom sort on top of the list and alphabetic after the custom sort.
User | Count |
---|---|
252 | |
107 | |
88 | |
51 | |
44 |