Hi Experts,
Sorting is only working in one direction - if ascending then it stays in it doesn't descend when click on icon.
I am using the below formula to sort items in my gallery.
Sort Icon (on select) =
Set(
varSortColumn,
"Title"
);
Set(
varSortDirection,
If(
varSortDirection = Ascending,
Ascending,
Descending
)
)
Then I have my gallery
Switch(
varSortColumn,
"Title",
SortByColumns(
Filter(
'DWP Technology & Service Register',
'Product / Service (Title)' = ComboBox1.Selected.'Product / Service (Title)' || IsBlank(ComboBox1.Selected.'Product / Service (Title)')
),
"Title",
If(
varSortColumn = Ascending,
Ascending,
Descending )
),
"Technology_x0020_Grouping",
SortByColumns(
Filter(
'DWP Technology & Service Register',
'Product / Service (Title)' = ComboBox1.Selected.'Product / Service (Title)' || IsBlank(ComboBox1.Selected.'Product / Service (Title)')
),
"Technology_x0020_Grouping",
If(
varSortColumn = Ascending,
Ascending,
Descending
)
)
)
Assuming that you want your sort icon to toggle the sort order, this logic should hopefully work better for you.
Set(
varSortColumn,
"Title"
);
Set(
varSortDirection,
Switch( varSortDirection,
Descending, Ascending,
Ascending, Descending,
Ascending
)
)
In addition to the above, if you modify the Items property of the gallery to reference varSortDirection only, that should hopefully work.
Switch(
varSortColumn,
"Title",
SortByColumns(
Filter(
'DWP Technology & Service Register',
'Product / Service (Title)' = ComboBox1.Selected.'Product / Service (Title)' || IsBlank(ComboBox1.Selected.'Product / Service (Title)')
),
"Title",
varSortDirection
),
"Technology_x0020_Grouping",
SortByColumns(
Filter(
'DWP Technology & Service Register',
'Product / Service (Title)' = ComboBox1.Selected.'Product / Service (Title)' || IsBlank(ComboBox1.Selected.'Product / Service (Title)')
),
"Technology_x0020_Grouping",
varSortDirection
)
)
@timl
Correct but using the variable varsortdirection gives me delegation warning to aviod that i was using
If(
varSortColumn = Ascending,
Ascending,
Descending )