Forum Discussion
Employee New Hire
Hello tamerj1 and Others,
I need to calculate new employees hired for the each respective month by using their HireDate
For example I need to calculate how many new employees got hired in every month and at the end of every year i need distinct count rather then showing them as sum. I have calculated but my bottom is not calculating right answer
Regards,
Sid
New Hires =
var minDate = MIN('Date'[Date])
var maxDate = MAX('Date'[Date])
return CALCULATE( COUNTROWS( 'Staff' ),
REMOVEFILTERS( 'Date'[Date])
'Staff'[HireDate] <= maxDate && 'Staff'[Hire Date] >= minDate
)Should work at any level of the date hierarchy
Hi Siddiq8686 ,
First you need to build a new "inactive" relationship like this
Your measures would beNew Hires = CALCULATE ( COUNTROWS ( VALUES ( Payroll_Merge_File[Employee #] ) ), USERELATIONSHIP ( Calendar_Table[Date],Payroll_Merge_File[Hire Date] ) )Total Staff = VAR LastDateInFilter = CALCULATE ( MAX (Payroll_Merge_File[Hire Date] ), USERELATIONSHIP ( Calendar_Table[Date],Payroll_Merge_File[Hire Date] ) ) VAR Result = CALCULATE ( COUNTROWS ( VALUES ( Payroll_Merge_File[Employee #] ) ), USERELATIONSHIP ( Calendar_Table[Date],Payroll_Merge_File[Hire Date] ), Calendar_Table[Date] <= LastDateInFilter ) RETURN ResultYour report shall look like this
Please note that currently your Calendar Table starts from 2019 while hiring data starts from 1976. Therefore you need to update you Calendat Table to include all missing dates.
Hope this answers your query. Have a great day!
6 Replies
- mh2587
Super User
No of Hires = Distinctcount(tablename(hiredate))
- Siddiq8686
Helper I
mh2587 i need monthly new hires. The measure you shared is only counting dates as a unqiue value
I am explain my problem below
Year Month totalStaff NewHires
2020 Jan 100 3
2020 Feb 110 7
2020 Mar 150 40
I dont want running totals of new hires in each month.
- tamerj1
Community Champion
Hi Siddiq8686 ,
First you need to build a new "inactive" relationship like this
Your measures would beNew Hires = CALCULATE ( COUNTROWS ( VALUES ( Payroll_Merge_File[Employee #] ) ), USERELATIONSHIP ( Calendar_Table[Date],Payroll_Merge_File[Hire Date] ) )Total Staff = VAR LastDateInFilter = CALCULATE ( MAX (Payroll_Merge_File[Hire Date] ), USERELATIONSHIP ( Calendar_Table[Date],Payroll_Merge_File[Hire Date] ) ) VAR Result = CALCULATE ( COUNTROWS ( VALUES ( Payroll_Merge_File[Employee #] ) ), USERELATIONSHIP ( Calendar_Table[Date],Payroll_Merge_File[Hire Date] ), Calendar_Table[Date] <= LastDateInFilter ) RETURN ResultYour report shall look like this
Please note that currently your Calendar Table starts from 2019 while hiring data starts from 1976. Therefore you need to update you Calendat Table to include all missing dates.
Hope this answers your query. Have a great day!- Siddiq8686
Helper I
Great This works. Thanks
- johnt75
Super User
New Hires =
var minDate = MIN('Date'[Date])
var maxDate = MAX('Date'[Date])
return CALCULATE( COUNTROWS( 'Staff' ),
REMOVEFILTERS( 'Date'[Date])
'Staff'[HireDate] <= maxDate && 'Staff'[Hire Date] >= minDate
)Should work at any level of the date hierarchy
- Siddiq8686
Helper I
Thanks Alot. This works