Forum Discussion
DAX to Include Someone in Average After their Hire Date Using Date Range Filter
Hi cmaloyb ,
Are you trying to get the number of employees who have been with the company for more than the average number of years of service? I'm sorry for not understanding your needs very well. Could you please provide some dummy data from the tables involved and then list one or two examples based on these dummy data based on real situations to illustrate the final result you want. It is better if you can provide a simiple sample pbix file with dummy data. Thank you.
Best Regards
Hi Anonymous ,
After creating my exampl .pbix file, it seems that I have a different issue than I thought I originally had. I have written my measures incorrectly to do what I'd like.
I am looking for a way to look at the average time recorded at each PayPeriod and then look at the overall average across the selected PayPeriods based on a dynamic Date Slicer. I am not able to attach a .pbix file, assuming my user permissions, so I will screenshot and provide tables here of what I have done with dummy data.
Employee Table
PayPeriod
| EmployeeID | HoursQuantity | Employees Time Table |
| ID001 | 38 | 1/15/2021 |
| ID001 | 40 | 2/15/2021 |
| ID001 | 40 | 3/15/2021 |
| ID001 | 25 | 4/15/2021 |
| ID001 | 42 | 5/15/2021 |
| ID001 | 40 | 6/15/2021 |
| ID001 | 45 | 7/15/2021 |
| ID002 | 40 | 2/15/2021 |
| ID002 | 41 | 3/15/2021 |
| ID002 | 35 | 4/15/2021 |
| ID002 | 41 | 5/15/2021 |
| ID002 | 40 | 6/15/2021 |
| ID002 | 32 | 7/15/2021 |
| ID003 | 50 | 2/15/2021 |
| ID003 | 43 | 3/15/2021 |
| ID003 | 44 | 4/15/2021 |
| ID003 | 40 | 5/15/2021 |
| ID003 | 39 | 6/15/2021 |
| ID003 | 41 | 7/15/2021 |
| ID004 | 40 | 3/15/2021 |
| ID004 | 34 | 4/15/2021 |
| ID004 | 28 | 5/15/2021 |
| ID005 | 41 | 3/15/2021 |
| ID005 | 40 | 4/15/2021 |
| ID005 | 40 | 5/15/2021 |
| ID005 | 40 | 6/15/2021 |
| ID005 | 44 | 7/15/2021 |
| ID006 | 40 | 3/15/2021 |
| ID006 | 48 | 4/15/2021 |
| ID006 | 32 | 5/15/2021 |
| ID006 | 36 | 6/15/2021 |
| ID006 | 44 | 7/15/2021 |
| ID007 | 40 | 4/15/2021 |
| ID007 | 40 | 5/15/2021 |
| ID007 | 39 | 6/15/2021 |
| ID007 | 41 | 7/15/2021 |
| ID008 | 45 | 4/15/2021 |
| ID008 | 44 | 5/15/2021 |
| ID008 | 46 | 6/15/2021 |
| ID008 | 42 | 7/15/2021 |
| ID009 | 47 | 5/15/2021 |
| ID009 | 40 | 6/15/2021 |
| ID009 | 38 | 7/15/2021 |
| ID010 | 40 | 5/15/2021 |
| ID010 | 40 | 6/15/2021 |
| ID010 | 40 | 7/15/2021 |
Relationships:
Employee 1 -> * Employees Time on EmployeeID
Dates 1 <> * Employees Time on Date and PayPeriod
DAX Measures:
Report Page with Current Results and Desired Results
I would like to get an average time across a certain range of Pay Periods. If someone has not been hired yet, I do not want to include them in the average.
I hope this helps,
Thanks!