Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Calculating After Hours

Hi 

I'm trying to calculate total tickets created during after hours. I'm able to calculate tickets during business hours, but after hours includes particular weekday times and different weekend times. I think I'm going to need an IF statement, but I'm not sure how to write the DAX in the parenthesis. 

After Hours = IF (Creation Date/Time is between 6pm and 6am on a Weekday OR on a Weekend ??), 1, 0

Thanks

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  Anonymous ,

    I created some data:

     

    Here are the steps you can follow:

    1. Create calculated column.

    Weekday =
    WEEKDAY('Table'[Date],2)
    After Hours =
    var _hour=HOUR('Table'[Date])
    return
    IF(
        _hour>=6 && _hour<=18 && NOT('Table'[Weekday] in {6,7})
       ,1,0)
    Calculating After Hours =
    COUNTX(
        FILTER(ALL('Table'),
        'Table'[After Hours]=0),[Ticket])

    2. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    I created some data:

     

    Here are the steps you can follow:

    1. Create calculated column.

    Weekday =
    WEEKDAY('Table'[Date],2)
    After Hours =
    var _hour=HOUR('Table'[Date])
    return
    IF(
        _hour>=6 && _hour<=18 && NOT('Table'[Weekday] in {6,7})
       ,1,0)
    Calculating After Hours =
    COUNTX(
        FILTER(ALL('Table'),
        'Table'[After Hours]=0),[Ticket])

    2. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly