Forum Discussion
Dax measures , multiple if's
- Anonymous1 year ago
Hi @Selded ,
To solve this logically, you would first group the records by employee and then sort each employee’s records by date so the days are processed in the correct order. As you go through each record, maintain a counter that tracks consecutive working days. If the status is PR, check whether the previous record was also PR and on the day immediately before if it is, increment the counter and if not reset it to one since a new streak begins. If the status is anything other than PR reset the counter to zero because the streak is broken. After updating the counter for each day apply the business rule: if the counter is exactly the 6th or 7th consecutive PR day, override the shift duration with 12, otherwise keep the shift duration as it is in the data. This process continues across all dates for each employee independently, with the counter resetting whenever there’s a break in presence.
Thank you
This works, thank you. are you able to assit with the 4th question?
Hi @Selded ,
To solve this logically, you would first group the records by employee and then sort each employee’s records by date so the days are processed in the correct order. As you go through each record, maintain a counter that tracks consecutive working days. If the status is PR, check whether the previous record was also PR and on the day immediately before if it is, increment the counter and if not reset it to one since a new streak begins. If the status is anything other than PR reset the counter to zero because the streak is broken. After updating the counter for each day apply the business rule: if the counter is exactly the 6th or 7th consecutive PR day, override the shift duration with 12, otherwise keep the shift duration as it is in the data. This process continues across all dates for each employee independently, with the counter resetting whenever there’s a break in presence.
Thank you