Forum Discussion

kaledjeff's avatar
kaledjeff
Icon for Advocate I rankAdvocate I
8 years ago
Solved

Number of employee between two dates

Hello DAX Experts,   I'm trying to figure out a formula that calculate the number of employee for each day between two dates. My table looks something like this:     I have a calendar table ...
  • Phil_Seamark's avatar
    8 years ago

    HI kaledjeff

     

    This calculated table uses an embedded date table

     

    Table = 
    VAR ExpandedTable =     
        GENERATE(
            CALENDAR(DATE(2017,1,1),TODAY()),
            FILTER(
                'Employees',
                [Date]>='Employees'[Start Date] &&
                [Date]< IF(ISBLANK('Employees'[End Date]),TODAY(),'Employees'[End Date])
                )
                )
                
    RETURN 
        SUMMARIZE(  
            ExpandedTable,
            [Date] , 
            "Count",COUNTROWS('Employees')
            )          

     

    and when plotted you get this..

     

  • Phil_Seamark's avatar
    Phil_Seamark
    8 years ago

    Hi kaledjeff

     

    Well done on getting it to work with your date table

     

    If you add [Department] to the final SUMMARIZE statement, you can then use this field as a filter

     

    RETURN 
        SUMMARIZE(  
            ExpandedTable,
    [Date] ,
    [Department] , "Count",COUNTROWS('Employees') )