I am looking to create calculated column/s that will achieve the following goal: I need to calculate the maximum date for a previous episode of care (see data below). I am able to use the earlier() function to get the maximum date for the first and last episode of care, but I need it to be the previous episode rather than just the first or last. I am using calculated columns rather than measures because I need person-level data and need to do further calculations.
This is my desired outcome:
What I am able to achieve using earlier() function:
When a person has more than two episodes is where my formulas stop working. My formulas are similar to this:
earliest date = calculate(min([date]), filter(table, [person] = earlier([person]))
I've looked on the internet and similar questions but haven't found an example that worked. Please help!