Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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 Date | End Date | |
Bob | 1/20/2010 | 2/4/2018 |
John | 5/4/2010 | 3/1/2019 |
Steve | 10/15/2013 | |
Joe | 4/9/2012 | |
Alice | 9/1/2016 | 11/1/2018 |
Nancy | 2/1/2019 | |
Kate | 3/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!
Solved! Go to Solution.
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
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
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?
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
64 |
User | Count |
---|---|
135 | |
122 | |
101 | |
71 | |
61 |