Forum Discussion

Kyle-92's avatar
Kyle-92
Frequent Visitor
6 years ago
Solved

Calculating submissions between 2 dates

Hi   In my organisation we are required to submit a document everyday. So I am trying to create a dynamic measure where you can select the date range and see the number of submissions per employee ...
  • jdbuchanan71's avatar
    jdbuchanan71
    6 years ago

    We can change the measure to a SUMX that way the individual counts calculate correctly at the manager level.

     

    Submissions = 
    SUMX ( 
        VALUES( 'employee register'[Employee ID] ),
        CALCULATE(
            VAR _First = FIRSTDATE ( Dates[Date] )
            VAR _Last = LASTDATE( Dates[Date])
            VAR _EFirst = MIN ( 'employee register'[hiring date] )
            VAR _ELast = MIN ( 'employee register'[leaving date] )
            VAR _Start = MAX ( _First, _EFirst )
            VAR _End = IF ( ISBLANK ( _ELast ), _Last, MIN ( _Last, _ELast ) )
            VAR Result = MAX( 0, DATEDIFF( _Start, _End, DAY ) +1 )
            RETURN Result
        )
    )