Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Dax measures , multiple if's

  1. I need a dax measure that will return the items in the blue based on the duration and first half, if first half is PR, the measure should return 12, otherwise, it should return what is in first...
  • Anonymous's avatar
    Anonymous
    1 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