Forum Discussion

Patriszjo's avatar
Patriszjo
Frequent Visitor
3 years ago
Solved

Average days running calculated for each date context

Dear All, I've got a table with Service Desk Tickets which in simplification has four columns: Ticket ID, Date Created, Date Closed and Days Running which is the amount od days between Date Created ...
  • Jihwan_Kim's avatar
    3 years ago

    Hi,

    I am not sure whether I understood your question correctly, but please check the below picture and the attached file.

     

     

     

     

    Expected measure: =
    VAR _newtable =
        ADDCOLUMNS (
            Data,
            "@Day running",
                IF (
                    Data[Date closed] <> BLANK (),
                    DATEDIFF ( Data[Date created], Data[Date closed], DAY ),
                    DATEDIFF ( Data[Date created], TODAY (), DAY )
                )
        )
    VAR _filternewtable =
        FILTER (
            _newtable,
            Data[Date closed] >= MIN ( 'Calendar'[Date] )
                && Data[Date created] <= MAX ( 'Calendar'[Date] )
        )
    RETURN
        IF (
            HASONEVALUE ( 'Calendar'[Month name] ),
            AVERAGEX ( _filternewtable, [@Day running] )
        )