Forum Discussion

leodm's avatar
leodm
Frequent Visitor
3 years ago
Solved

Difference between dates on different rows and same column AFTER filtering

Database sample   Data de início real Squad Art 03/01/2022 17:30:00 Squad1 Art1 03/01/2022 22:00:43 Squad2 Art1 03/01/2022 22:30:00 Squad3 Art2 04/01/2022 09:00:00 Squad4 #...
  • FreemanZ's avatar
    3 years ago

    hi leodm 

    try to add plot all the columns with a measure like:

    Result = 
    VAR _date = MAX(TableName[Date])
    VAR _datepre =
    MAXX(
        FILTER(
            ALLSELECTED(TableName),
            TableName[Date]<_date
        ),
         TableName[Date]
    )
    VAR _Difference= _date - _datepre
    VAR _Days = INT(_Difference)
    VAR _Hours = HOUR(_Difference)
    VAR _Minutes = MINUTE(_Difference)
    VAR _Seconds = SECOND(_Difference)
    VAR _DaysToHours = _Days * 24
    VAR _TotalHours = _DaysToHours + _Hours
    RETURN
    IF(
        _datepre<>BLANK(),
        FORMAT(_TotalHours, "00") & ":" & FORMAT(_Minutes, "00") & ":" & FORMAT(_Seconds,"00"),
        " "
    )

     

    it worked like: