Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Using date slicer to return number of active employees

Hi everyone, new PowerBI user here 🙂 

 

I am looking to create a dashboard that displays the number of customer transactions and the number of employees we had to fulfill those transactions. The first piece I have gotten since each Transaction has a Transaction date and I linked that to a Date table that has all the days between 2018 and 2019. By using a slicer on the Date table, I can return the number of transactions that fell in that range. 

 

What I would like to do now is to use the same date slicer above to also tell me how many active employees I had during that period. 

 

I've read about using enumerated tables to do this but I'm sure how to actually get started here. I'm also unsure if this is the right approach if I have thousands of employees in my file. 

 

Here's a sample data set (my actual data set would have thousands of people). 

 

 Start DateEnd Date
Bob1/20/20102/4/2018
John5/4/20103/1/2019
Steve10/15/2013 
Joe4/9/2012 
Alice9/1/201611/1/2018
Nancy2/1/2019 
Kate3/1/2019 

 

If I set the date range from 1/1/2018 to 12/31/2018, I should get 3 (John, Steve, Joe)

If I set this to 1/1/2019 to 12/31/2019, I should get 4. (Steve, Joe, Nancy, Kate)

 

I would only count the individual as active if their start date is before the end of the date range and if their end date (if there is one), is after the end of the date range. 

 

Thank you in advance for your help!

 

1 ACCEPTED SOLUTION
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

Could you please share your filter logic with the sample, based on my understand, 1/1/2019 to 12/31/2019 should only have Steve and Joe.

In this scenario, we can use the following DAx query:

Measure = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),AND(Table1[Start Date] <= MIN('Table'[Date]),OR(Table1[End Date] = BLANK(),Table1[End Date] >= MAX('Table'[Date])))))

Best Regards,

Teige

View solution in original post

2 REPLIES 2
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

Could you please share your filter logic with the sample, based on my understand, 1/1/2019 to 12/31/2019 should only have Steve and Joe.

In this scenario, we can use the following DAx query:

Measure = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),AND(Table1[Start Date] <= MIN('Table'[Date]),OR(Table1[End Date] = BLANK(),Table1[End Date] >= MAX('Table'[Date])))))

Best Regards,

Teige

Anonymous
Not applicable

Hi @TeigeGao ,

 

You raise a good point. I was not consistent in my filtering of the start and end dates. 

 

If I understand your DAX query correctly:

Table1 is my table with the Employees and their start and end dates.

'Table'[Date] is reading the slicer values?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.