I have the following formula inside a Gallery Items property:-
Switch(SortComboBox.Selected.Value,
"Due Date",
SortByColumns(finalResult,
"DueDateRow",SortOrder.Ascending
),
"Status",
SortByColumns(finalResult,
"Status",SortOrder.Ascending
),
"Plan",
SortByColumns(finalResult,
"PlanTitle",SortOrder.Ascending
)
)
and the following code inside a search button OnSelect , to get all the Planner Tasks inside all the planners:-
Set(varInProgress,true);
ClearCollect(finalResult,{PlanTitle:"",TaskTitle:"",Status:"",AssignedToUserId:"",DueDate:"",DueDateRow:"",TaskID:"",PlannerID:"",GroupID:"",Assignment:Table()});
Clear(colRelatedGroupsIds);
Clear(colRelatedPlanners);
Clear(colRelatedPlannerTasks);
ClearCollect(colTeamSitesItem,Filter('Team Sites',1=1));
ClearCollect(colAllGroups,Office365Groups.ListGroups().value);
ForAll(colAllGroups As group,
ForAll(colTeamSitesItem As i2,
If(Lower(group.displayName)=Lower(i2.'Team Site Name'),
Collect(colRelatedGroupsIds,group.id))));
ForAll(colRelatedGroupsIds As group,
Collect(colRelatedPlanners,
Planner.ListGroupPlans(group.Value).value);
ForAll(colRelatedPlanners As planner,
Collect(colRelatedPlannerTasks,
Filter(
Planner.ListTasksV3(planner.id, group.Value).value,
(IsBlank(assignedToComboBox.Selected) || assignedToComboBox.Selected.Id in _assignments.userId) And
(IsEmpty(StatusComboBox.SelectedItems) || percentComplete in (StatusComboBox.SelectedItems.ID))
));
ForAll(colRelatedPlannerTasks As task,
ForAll(task._assignments As taskAssignment,
If(!IsBlank(task.title) And IsEmpty(Filter(finalResult,TaskID=task.id)),
Patch(finalResult,Defaults(finalResult),
{
PlanTitle:planner.title,
AssignedToUserId:taskAssignment.userId,
Status:If(Text(task.percentComplete)="100","Completed",
If(Text(task.percentComplete)="50","In Progress",
If(Text(task.percentComplete)="0","Not Started"))),
TaskTitle:task.title,
DueDate:Text(DateTimeValue(task.dueDateTime), "dd/mm/yyyy"),
DueDateRow:DateTimeValue(task.dueDateTime),
TaskID:task.id,
GroupID:group.Value,
PlannerID:planner.id,
Assignment:task._assignments
}),false)
));RemoveIf(colRelatedPlannerTasks,true));RemoveIf(colRelatedPlanners,true));
Set(varInProgress,false);
now if i select the sort value as "Due Date", the items will not get sorted by the due date, any advice why?
Here is a sample of the results:-

Thanks