web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sort Planner Tasks by ...
Power Apps
Unanswered

Sort Planner Tasks by dueDateTime is not working correclty

(2) ShareShare
ReportReport
Posted on by 1,857 Season of Giving Solutions 2025

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:-

 

 

johnjohnPter_0-1720365196301.png

 

 

Thanks

Categories:
I have the same question (0)
  • Sunil Kumar Pashikanti Profile Picture
    1,628 Moderator on at

    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

    Solved: Planner Create Task - Not setting correct due date... - Power Platform Community (microsoft.com)

     

    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.

    Sunil Pashikanti - Tech Blog: PowerApps

  • johnjohnPter Profile Picture
    1,857 Season of Giving Solutions 2025 on at

    @SunilPashikanti are you using AI to post answers? as i got similar unusful answer using a well known AI..

  • EddieE Profile Picture
    4,641 Moderator on at

    @johnjohnPter 

    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

  • johnjohnPter Profile Picture
    1,857 Season of Giving Solutions 2025 on at

     

    @EddieE yes the data is correct it is coming from the Planner connector

  • EddieE Profile Picture
    4,641 Moderator on at

    @johnjohnPter 

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 514

#2
WarrenBelz Profile Picture

WarrenBelz 419 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 295

Last 30 days Overall leaderboard