this is my gallery items
Sort(
Filter(
'Main Form Information',
FormTypeDrop.Selected.Result in Concat('Form Type',Value,","),
AuditTypeDrop.Selected.Result in Concat('Audit Type',Value,","),
AuditorDrop.Selected.Result in Auditor.DisplayName,
RegionDrop.Selected.Result in Region.Value,
DateCheck <= 'Inspection Date',
Switch(SearchNonCon.Selected.Value,
"All",
true ,
"Yes",
If(CountRows(Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID))
>
0,
true,
false
),
"No",
If(
Not(
CountRows(
Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID)
)
>
0
),
true,
false
)
)
),
sortColumn,
AorD
)
i have some buttons that change the value of "sortColumn" to a text input of the applicable column that you want to sort by. the variable changes, I can see that. but it doesn't actually change how the list shows up in the gallery.
AorD is the same idea but it changes from ascending or descending when a button is pressed.
Hi @Anonymous :
I suggest you save the result of this code to a collection and then check if the "Inspection Date" field exists.
For example:
ClearCollect(Thecollection,
Filter(
'Main Form Information',
FormTypeDrop.Selected.Result in Concat('Form Type',Value,","),
AuditTypeDrop.Selected.Result in Concat('Audit Type',Value,","),
AuditorDrop.Selected.Result in Auditor.DisplayName,
RegionDrop.Selected.Result in Region.Value,
DateCheck <= 'Inspection Date',
Switch(SearchNonCon.Selected.Value,
"All",
true ,
"Yes",
If(CountRows(Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID))
>
0,
true,
false
),
"No",
If(
Not(
CountRows(
Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID)
)
>
0
),
true,
false
)
)
))
Best Regards,
Bof
I've used this code for a good bit with no issue then i went to add the filter and for whatever reason it won't identify a column I even tried hard coding the column name and thats not even working.
SortByColumns(
Filter(
'Main Form Information',
FormTypeDrop.Selected.Result in Concat('Form Type',Value,","),
AuditTypeDrop.Selected.Result in Concat('Audit Type',Value,","),
AuditorDrop.Selected.Result in Auditor.DisplayName,
RegionDrop.Selected.Result in Region.Value,
DateCheck <= 'Inspection Date',
Switch(SearchNonCon.Selected.Value,
"All",
true ,
"Yes",
If(CountRows(Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID))
>
0,
true,
false
),
"No",
If(
Not(
CountRows(
Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID)
)
>
0
),
true,
false
)
)
),
"Inspection Date"
)
Hi @Anonymous :
Thanks for @mdevaney 's solution, I made a test but did not encounted any problem.
My code:
SortByColumns(MyPhoto,sortColumn,AorD) /*MyPhoto is my data source*/
Could you check if the result of this code is empty?
Filter(
'Main Form Information',
FormTypeDrop.Selected.Result in Concat('Form Type',Value,","),
AuditTypeDrop.Selected.Result in Concat('Audit Type',Value,","),
AuditorDrop.Selected.Result in Auditor.DisplayName,
RegionDrop.Selected.Result in Region.Value,
DateCheck <= 'Inspection Date',
Switch(SearchNonCon.Selected.Value,
"All",
true ,
"Yes",
If(CountRows(Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID))
>
0,
true,
false
),
"No",
If(
Not(
CountRows(
Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID)
)
>
0
),
true,
false
)
)
)
Best Regards,
Bof
it shows the gallery completely empty when i do that.
I thought that as well and it's not working with that either
@Anonymous
The issue is you are trying to supply a screen name to the SORT function. This cannot be done. Instead, you must use the SORTCOLUMNS function.
SortColumns(
your_filter_code_here,
sortColumn,
AorD
)
---
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."
this is in the app onStart
Set(AorD,Descending);
Set(sortColumn,"Inspection Date")
this is in the buttons' onSelect field
//button one
Set(sortColumn,"Inspection Date")
//button two
Set(sortColumn,"Auditor")
and this is in the inverting order icon
Set(AorD,If(AorD = Descending,Ascending,Descending));
@Anonymous
It would be a good idea to share the code you are using to SET SortColumn and AorD. The code you supplied is fine, but it doesn't tell the whole story.
---
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."
MS.Ragavendar
32
Michael E. Gernaey
19
Super User 2025 Season 1
Rajkumar_M
16
Super User 2025 Season 1