Forum Discussion

ScottA's avatar
ScottA
Frequent Visitor
4 years ago
Solved

Looping / Custom Function Question

I have a table of employees that need to complete a course. There are two different ranks of employees, “C” and “F”. They must each complete the course in the window between their ‘target date’ and ‘...
  • mahoneypat's avatar
    4 years ago

    This is a challenging one. I didn't have time to finish it, but the attached pbix shows one way to approach this with List.Accumulate. It iterates over the list of Course dates and generates the first X Employees for which the Course date is between the Target and Expiry dates. Those Employees are removed from the list and the remaining employees are passed to the next iteration, and so on. This generates the list of "C" employees and you could adapt same approach for the "F" employees. From there you can merge the Employee table with this resulting table to get your desired result.

     

    Note that Employee 16 didn't have a fit for any of the Course dates. Also, this approach is not very performant, so it would be slow if your tables are large.

     

    Pat