Forum Discussion
Anonymous
6 years agoNot applicable
Calculating Consecutive Days Worked by Staff
Hi, I'm currently stuck trying to create a measure that will calculate the number of consecutive days worked by staff across a given period of time (date is an adjustable filter, so people can se...
v-joesh-msft
Solution Sage
6 years agoHi Anonymous ,
I am not sure if it is the result you want, you can try the measure below:
consecutive days =
VAR t =
ADDCOLUMNS (
ADDCOLUMNS (
'Table',
"LastRestDay",
VAR currentday = [Date]
VAR result =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER ( 'Table', [Hours Worked] + 0 = 0 && 'Table'[Date] < currentday )
)
RETURN
IF (
result = BLANK (),
CALCULATE ( MIN ( 'Table'[Date] ), 'Table' ) - 1,
result
)
),
"cDay", IF ( [Hours Worked] = 0, 0, DATEDIFF ( [LastRestDay], [Date], DAY ) )
)
RETURN
MAXX ( t, [cDay] )Results are as follows:
Here is a demo, please try it:
Best Regards,
Community Support Team _ Joey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.