Forum Discussion

shaye101223's avatar
shaye101223
Frequent Visitor
1 year ago
Solved

Calculate days overdue based on date column

I was tasked with making a ticket system, i have that completed but now I need to make a dashborad and one of the things is to show how many tickets are overdue for only the new and in progress tickets. I have a date table and a "due date" column.

Thank you 

  • Hi shaye101223 ,

     

    To count the number of overdue tickets in Power BI for only those with a status of "New" or "In Progress," you can create a DAX measure that compares the Due Date column with today's date while filtering by the required statuses. The measure can be written as follows:

    Overdue Tickets = 
    VAR TodayDate = TODAY()
    
    RETURN
    CALCULATE(
        COUNT('Tickets'[Ticket ID]), 
        'Tickets'[Due Date] < TodayDate, 
        'Tickets'[Status] IN {"New", "In Progress"}
    )
    

    This measure first defines TodayDate as the current date using TODAY(), then calculates the count of ticket IDs where the due date is earlier than today and the ticket status is either "New" or "In Progress." If you want to allow users to dynamically choose the date for comparison using a slicer, you can modify the measure to reference the selected date from a Date Table:

    Overdue Tickets (Dynamic) = 
    VAR SelectedDate = MAX('Date'[Date])
    
    RETURN
    CALCULATE(
        COUNT('Tickets'[Ticket ID]), 
        'Tickets'[Due Date] < SelectedDate, 
        'Tickets'[Status] IN {"New", "In Progress"}
    )
    

    This version retrieves the maximum selected date from the Date Table slicer instead of using TODAY(). To display the measure in a dashboard, you can use a Card visual to show the count of overdue tickets, a Table/Matrix visual to list ticket details, and a Date slicer if using the dynamic version. This setup will allow users to monitor overdue tickets interactively while maintaining visibility into key ticketing metrics.

     

    Best regards,

3 Replies

  • Hi shaye101223 ,

     

    To count the number of overdue tickets in Power BI for only those with a status of "New" or "In Progress," you can create a DAX measure that compares the Due Date column with today's date while filtering by the required statuses. The measure can be written as follows:

    Overdue Tickets = 
    VAR TodayDate = TODAY()
    
    RETURN
    CALCULATE(
        COUNT('Tickets'[Ticket ID]), 
        'Tickets'[Due Date] < TodayDate, 
        'Tickets'[Status] IN {"New", "In Progress"}
    )
    

    This measure first defines TodayDate as the current date using TODAY(), then calculates the count of ticket IDs where the due date is earlier than today and the ticket status is either "New" or "In Progress." If you want to allow users to dynamically choose the date for comparison using a slicer, you can modify the measure to reference the selected date from a Date Table:

    Overdue Tickets (Dynamic) = 
    VAR SelectedDate = MAX('Date'[Date])
    
    RETURN
    CALCULATE(
        COUNT('Tickets'[Ticket ID]), 
        'Tickets'[Due Date] < SelectedDate, 
        'Tickets'[Status] IN {"New", "In Progress"}
    )
    

    This version retrieves the maximum selected date from the Date Table slicer instead of using TODAY(). To display the measure in a dashboard, you can use a Card visual to show the count of overdue tickets, a Table/Matrix visual to list ticket details, and a Date slicer if using the dynamic version. This setup will allow users to monitor overdue tickets interactively while maintaining visibility into key ticketing metrics.

     

    Best regards,

    • shaye101223's avatar
      shaye101223
      Frequent Visitor

      Hello, this worked up until about a week ago, it just started counting how many tickets there was in 'new' and 'in progress'. is there a way to fix it? (i went the dynamic way)

  • Anonymous's avatar
    Anonymous
    Not applicable

    shaye101223,

    Thanks for the reply from DataNinja777.

     

    I agree with DataNinja777 that you could directly create a measure to filter the ticket status and count based on this filtered result.

     

    Please test on your side, and mark DataNinja777's reply as the answer if it works on your side.

    Thanks for your cooperation.

     

    Best Regards,

    Qi