Simple Adding and Subtracting algorithm to get a current amount

59 Views Asked by At

So this is my first post and its probably a really dumb question but I cannot get my head around a proper algorithm to handle the following situation.

I have a dataset that contains employees who have left an organisation, employees who have started at the organisation, and employees who havent either left or start at the organisation.

Example 1:
EmployeesStart: 0
EmployeesGone: 0
EmployeesRemain: 50

Example 2:
EmployeesStart: 10
EmployeesGone: 20
EmployeesRemain: 100

Example 3:
EmployeesStart: 0
EmployeesGone: 29
EmployeesRemain: 9

I am looking for an algorithm that determines the number of employees given these numbers.

Initially I thought

CurrentEmployees = EmployeesRemain + EmployeesStart - EmployeesGone

which would be correct for the first 2 examples but in example 3 I would end up with -20 employees which is incorrect.

Is there a simple sum I can use to get this correct, or do I have to come up with an algorithm to deal with each of the possible scenarios (e.g. Employees Gone > Employees Remain, Employees Start = Employees Gone, ect)

2

There are 2 best solutions below

0
On

The terms are not well defined. you either need to modify the term employeesstart, or define a new term "initial employees." Employees start probably means employees entering, not who were there initially. In that case example 3 would make more sense.

EmployeesRemain has to be $\ge 0$

EmployeesInitial = EmployeesGone + EmployeesRemain - EmployeesEnter

So in this case Currentemployees = employeesremain, but there are other possibilities depending on who left when and what group is included in the other. Without concise definitions, you may not be able to generate a definite result.

0
On

What it sounds like is that there is some point in the past (call it $T$) that we're thinking of, and

  • EmployeesStart is the number of people who are employees now, but were not employees at time $T$,
  • EmployeesGone is the number of people who were employees at time $T$, but are not employees now, and
  • EmployeesRemain is the number of people who were employees at time $T$ and are employees now (regardless of whether or not they left and came back in the meantime).

If this is the case, then the number of people who are employees now is just EmployeesStart + EmployeesRemain. We don't need to subtract the employees in EmployeesGone because they were never counted in the first place.