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
I still think it's the data - nothing to do with your code. I'd be finding that record in Planner and inspecting the date for something off or data type mismatch, eg TEXT instead of DATE type
The record with 16/07/2024 is way off where it should be whereas all the others are correct. Must be the data
@EddieE yes the data is correct it is coming from the Planner connector
Have you checked that this isn't a data error? Seems all the other dates are in order, just not the 2 you have highlighted. I'd be looking into the data first to make sure it is correct
@SunilPashikanti are you using AI to post answers? as i got similar unusful answer using a well known AI..
Hi @johnjohnPter,
It appears that the sorting by due date isn’t working as expected in your Power Apps gallery. Please check the below items properly again.
Check Data Types
Verify the Formula
Debugging Steps
Check Date Formatting
References:
How can I sort Planner tasks within buckets by due date automatically - Microsoft Community
Microsoft To Do Sorting by Due Date is not chronologically correct - Microsoft Community
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.
WarrenBelz
146,635
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional