Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Sort Planner Tasks by dueDateTime is not working correclty

(2) ShareShare
ReportReport
Posted on by 1,542 Super User 2024 Season 1

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

  • EddieE Profile Picture
    4,641 Super User 2025 Season 1 on at
    Re: Sort Planner Tasks by dueDateTime is not working correclty

    @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

  • johnjohnPter Profile Picture
    1,542 Super User 2024 Season 1 on at
    Re: Sort Planner Tasks by dueDateTime is not working correclty

     

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

  • EddieE Profile Picture
    4,641 Super User 2025 Season 1 on at
    Re: Sort Planner Tasks by dueDateTime is not working correclty

    @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,542 Super User 2024 Season 1 on at
    Re: Sort Planner Tasks by dueDateTime is not working correclty

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

  • SunilPashikanti Profile Picture
    731 Super User 2025 Season 1 on at
    Re: Sort Planner Tasks by dueDateTime is not working correclty

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,635 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard