Forum Discussion

pgd's avatar
pgd
Frequent Visitor
3 years ago
Solved

Return difference between two dates if criteria matches

My dashboard linked to a SharePoint list. The sharepoint list has the following columns: the barcode value on the library book, who checked out the library book, the time they checked out the library...
  • v-zhangti's avatar
    3 years ago

    Hi, pgd 

     

    If you want to try to solve the problem with Measure, you can try the following methods.
    Measure:

    Difference = 
    VAR _last =
        CALCULATE(MAX('Table'[Date]), 
            FILTER (ALL ( 'Table' ),
                [Book Barcode Value] = SELECTEDVALUE ( 'Table'[Book Barcode Value] )
                    && [Date] < SELECTEDVALUE ( 'Table'[Date] ) ))
    RETURN
        IF (
            _last <> BLANK (),
            DATEDIFF ( _last, SELECTEDVALUE ( 'Table'[Date] ), DAY ),
            0 )

    Is this the result you expect?

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.