Forum Discussion
Anonymous
3 years agoNot applicable
DATEDIFF for repeated rows
Hey everybody! I have an issue and would be appreciated for your help. I have a table below that contains information about power station's working time. Column 1 shows us when station works prop...
- 3 years ago
Hi Anonymous
It was a wrong solution.Please refer to attached file with the correct solution
Down Order = --column IF ( 'Nizhny Tagil#1'[HP GOX] = 1, RANKX ( FILTER ( 'Nizhny Tagil#1', 'Nizhny Tagil#1'[HP GOX] = 1 ), VAR T1 = FILTER ( 'Nizhny Tagil#1', 'Nizhny Tagil#1'[Date] <= EARLIER ( 'Nizhny Tagil#1'[Date] ) ) RETURN COUNTROWS (T1) - SUMX ( T1, 'Nizhny Tagil#1'[HP GOX] ),, ASC, Dense ) )Start Time = --measure IF ( NOT ISBLANK ( SELECTEDVALUE ( 'Nizhny Tagil#1'[Down Order] ) ), MIN ( 'Nizhny Tagil#1'[Date] ) )End Time = --measure IF ( NOT ISBLANK ( SELECTEDVALUE ( 'Nizhny Tagil#1'[Down Order] ) ), MAX ( 'Nizhny Tagil#1'[Date] ) )Downtime = --measure SUMX ( VALUES ( 'Nizhny Tagil#1'[Down Order] ), IF ( 'Nizhny Tagil#1'[Down Order] <> BLANK (), DATEDIFF ( [Start Time], [End Time], MINUTE ) ) )
tamerj1
3 years agoCommunity Champion
Hi Anonymous
you need to create a calculated column that sort the down occurances in order. Then you can place this column in the table visual followed by the following measures.
Down Order = --column
IF (
'Table'[Column1] = 1,
SUMX (
FILTER ( 'Table', 'Table'[Date] <= EARLIER ( 'Table'[Date] ) ),
'Table'[Column1]
)
)Start Time = --measure
MIN ( 'Table'[Date] )End Time = --measure
MAX ( 'Table'[Date] )Downtime = --measure
SUMX (
VALUES ( 'Table'[Down Order] ),
IF (
'Table'[Down Order] <> BLANK (),
DATEDIFF ( [Satrt Time], [End Time], MINUTE)
)
)