Forum Discussion
Creating for loop in measure
Thank you for your interest! I'm happy to clear things up, if my response will leave you with more questions please feel free to ask me.
When this user was hired (8-Nov_2021) vacation days started accruing.
When she took her first vacation (Index = 1) which lasted 8 days she had 18.87 days accrued thus balance after vacation was 10.87 days.
From first vacation to second one, she accrued 23.47 days, but she had 10.87 days left from previous vacation, company's policy indicates that you can't have more than 24 days accrued, So when she took second vacation (Index = 2) she had MIN(24, 23.47+10.87) vacation days which is 24 and vacation lasted for 10 days thus she was left with 14 vacation days on her balance.
From second to third vacation she accrued 7.56 days. Third Vacation lasted 4 days (Index=3) and after this she was left with MIN(24, 7.56+14) - 4 = 17.56 vaction days on her balance.
and it goes on, I want to have vacation balance for today for each employee, so we can inform employees if they are near 24 days or already have 24 days and aren't getting vacation days anymore to take their well deserved vacations.
If I can manage to count balance after final vacation, which is 12.88 in this case, it will be easy to calculate vacation balance for today.
Problem is that for each vacation I need to know previous vacation balance to determine how many days they have left after this vacation on their balance.
Does this make things a bit clearer?
Give me a moment, your case is a tricky. Did you think about a model ?