Forum Discussion

dupreem's avatar
dupreem
Frequent Visitor
6 years ago
Solved

Headcount Over Time From Transactional Data

Hello,

 

I am working on building Turnover functionality and need to know headcount at a certain point in time.  The transactional data I am using looks something like this:

 

Employee ID 

Event Date 

Status

1

1/1/20

Active 

2

1/1/20

Active 

3

2/1/20 

Active 

1

3/1/20

Terminated 

2

3/1/20

Active 

3

3/1/20

Active 

1

4/1/20

Active

 

Based on the transactional data above I would expect to see end of the month headcount for each month to be: Jan = 2, Feb = 3, Mar = 2, Apr = 3.

 

Employees will have multiple transactions for their Employee ID.

 

Any help is greatly appreciated!

 

  • dupreem -

    Measure 14 = 
        VAR __Date = MAX([Event Date ])
        VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
        VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && ([Status]="Terminated" || [Status]="Retiree" || [Status]="Dead")),"ID",[Employee ID ]))
    RETURN
        COUNTROWS(EXCEPT(__Active, __Term))

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    dupreem - See attached PBIX file below sig, Page 14

    Measure 14 = 
        VAR __Date = MAX([Event Date ])
        VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
        VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Terminated"),"ID",[Employee ID ]))
    RETURN
        COUNTROWS(EXCEPT(__Active, __Term))

     

    • dupreem's avatar
      dupreem
      Frequent Visitor

      Greg_Deckler  Thank you so much!  If I have multiple "Terminated" statuses (i.e. "Terminated, Retiree), how would I update the Measure?

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        dupreem -

        Measure 14 = 
            VAR __Date = MAX([Event Date ])
            VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
            VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && ([Status]="Terminated" || [Status]="Retiree" || [Status]="Dead")),"ID",[Employee ID ]))
        RETURN
            COUNTROWS(EXCEPT(__Active, __Term))