none
Filter tasks that have worked assigned for today RRS feed

  • Question

  • I would like to generate a report that displays tasks which have work allocated to them today. Like the resource usage view, but for a single day, and for it to only display those tasks that have time allocated to them on that day. Is it possible to create a filter that does this?
    Tuesday, September 8, 2015 11:15 PM

Answers

  • Yes, I see that the assignment intervals don't work if you have manually edited the work in the usage views.

    This one does what you want by looking directly at the time scaled data.  The work scheduled for today is written into the Text30 field, so you need to add that field to your table.  You also need to edit the macro if Flag20 or Text30 are not available.  I added the filter specification and application in a couple lines at the end.  Let me know if it works for you.

    Sub WorkToday() Dim t As Task Dim tsvs As TimeScaleValues Dim tsv As TimeScaleValue 'Examine each task for work today For Each t In ActiveProject.Tasks If Not t Is Nothing Then

                t.Flag20 = False
                t.Text30 = ""

    Set tsvs = t.TimeScaleData(StartDate:=Date, EndDate:=Date, Type:=pjTaskTimescaledWork, _ TimeScaleUnit:=pjTimescaleDays, Count:=1) For Each tsv In tsvs If Val(tsv.value) > 0 Then t.Flag20 = True t.Text30 = "WorkToday: " & Val(tsv.value) / 60 & "h" End If Next tsv End If Next t 'Specify and apply filter to show only tasks with work today FilterEdit Name:="WorkToday", Create:=True, OverwriteExisting:=True, TaskFilter:=True, _ FieldName:="Flag20", Test:="Equals", value:="Yes", ShowSummaryTasks:=True FilterApply Name:="WorkToday" End Sub



    • Marked as answer by muaddib32 Thursday, September 10, 2015 9:55 PM
    • Edited by Tom BoyleBPC Friday, September 11, 2015 3:00 PM Added initial field clearing statements in code.
    Thursday, September 10, 2015 3:04 PM

All replies

  • Here's a little macro that sets the Flag20 field for tasks with any assigned work for today (00:00 to 23:59:59).  Run the macro, then set up a filter for Flag20.  I hope this works for you. tom

    Sub WorkToday()
    
        Dim t As Task
        Dim ta As Assignment
        Dim WorkToday As Boolean
        
        For Each t In ActiveProject.Tasks
            If Not t Is Nothing Then
                WorkToday = False
            
                For Each ta In t.Assignments
                    If ta.Start < (Date + 1) And ta.Finish > Date Then WorkToday = True
                Next ta
                
                t.Flag20 = WorkToday
            End If
        Next t
    End Sub
    

     
    Wednesday, September 9, 2015 2:32 PM
  • Thanks Tom,

    That's a great suggestion. Unfortunately, that picks up any task that is between its start and end dates, regardless of whether any work has been assigned today. I frequently have tasks that run in the background and get pushed to the following day if something more urgent comes up.

    What I would really like is to pull up anything where the hours assigned for today is > 0 and for the number of hours to be displayed. This must be stored somewhere as it is displayed in the resource usage view.

    Wednesday, September 9, 2015 11:00 PM
  • Yes, I see that the assignment intervals don't work if you have manually edited the work in the usage views.

    This one does what you want by looking directly at the time scaled data.  The work scheduled for today is written into the Text30 field, so you need to add that field to your table.  You also need to edit the macro if Flag20 or Text30 are not available.  I added the filter specification and application in a couple lines at the end.  Let me know if it works for you.

    Sub WorkToday() Dim t As Task Dim tsvs As TimeScaleValues Dim tsv As TimeScaleValue 'Examine each task for work today For Each t In ActiveProject.Tasks If Not t Is Nothing Then

                t.Flag20 = False
                t.Text30 = ""

    Set tsvs = t.TimeScaleData(StartDate:=Date, EndDate:=Date, Type:=pjTaskTimescaledWork, _ TimeScaleUnit:=pjTimescaleDays, Count:=1) For Each tsv In tsvs If Val(tsv.value) > 0 Then t.Flag20 = True t.Text30 = "WorkToday: " & Val(tsv.value) / 60 & "h" End If Next tsv End If Next t 'Specify and apply filter to show only tasks with work today FilterEdit Name:="WorkToday", Create:=True, OverwriteExisting:=True, TaskFilter:=True, _ FieldName:="Flag20", Test:="Equals", value:="Yes", ShowSummaryTasks:=True FilterApply Name:="WorkToday" End Sub



    • Marked as answer by muaddib32 Thursday, September 10, 2015 9:55 PM
    • Edited by Tom BoyleBPC Friday, September 11, 2015 3:00 PM Added initial field clearing statements in code.
    Thursday, September 10, 2015 3:04 PM
  • Thanks Tom, that's fantastic. Just what I was after. As a bonus it also picks up tasks that are scheduled to be completed but have not been marked as completed.

    I must admit I find it odd that this is not included 'out of the box' in Project. Surely I am not the only person who would find a 'To Do' list useful.

    Regards,
    Ben

    Thursday, September 10, 2015 9:55 PM
  • I realised after working with it for a bit that, of course, it is not automatically picking up overdue tasks. Merely that the flag hasn't been updated since yesterday. So I added a bit to the macro to update the values for other tasks.

    Sub WorkToday()

        Dim t As Task
        Dim tsvs As TimeScaleValues
        Dim tsv As TimeScaleValue
        
        'Examine each task for work today
        For Each t In ActiveProject.Tasks
            If Not t Is Nothing Then
                Set tsvs = t.TimeScaleData(StartDate:=Date, EndDate:=Date, Type:=pjTaskTimescaledWork, _
                    TimeScaleUnit:=pjTimescaleDays, Count:=1)
                For Each tsv In tsvs
                    If Val(tsv.Value) > 0 Then
                        t.Flag20 = True
                        t.Text30 = Val(tsv.Value) / 60
                        If t.Text30 = 1 Then
                            t.Text30 = t.Text30 & " hr"
                        Else
                            t.Text30 = t.Text30 & " hrs"
                        End If
                    ElseIf t.Finish < Date And t.PercentComplete < 100 Then
                        t.Flag20 = True
                        t.Text30 = Empty
                    Else
                        t.Flag20 = False
                        t.Text30 = Empty
                    End If
                Next tsv
            End If
        Next t
        'Specify and apply filter to show only tasks with work today
         FilterEdit Name:="WorkToday", Create:=True, OverwriteExisting:=True, TaskFilter:=True, _
             FieldName:="Flag20", Test:="Equals", Value:="Yes", ShowSummaryTasks:=True
         FilterApply Name:="WorkToday"

    End Sub

    Thursday, September 10, 2015 11:29 PM
  • Hi Ben,

    I'm glad I helped you get a start.  I also appreciate your restoring the step to reset the fields, which I had inadvertently removed in a quick code clean of the second macro.  I'll try to edit that post to fix the omission.

    Thanks for the positive feedback. tom 

    Friday, September 11, 2015 2:55 PM
  • A further question. I have created a report based on a filter using the Flag20 field. I have found that sub tasks only appear on the report if they are displayed on the Gantt chart. If only the summary task is displayed they don't appear. As soon as I expand a summary task to show all the sub tasks, then they appear.

    Why this is occurring? And how can I stop if from happening?


    • Edited by muaddib32 Sunday, September 20, 2015 11:33 PM
    Sunday, September 20, 2015 11:32 PM