Forum Discussion

Rustami4's avatar
Rustami4
Helper II
8 years ago
Solved

Count Of Days

Guys! I was seeking a similar topic for this, but couldn't find it.   The point is I have a set of oil wells, each of them has a number that identifies it. Another words a set of numbers... ANd I ...
  • danextian's avatar
    danextian
    8 years ago

    hI Rustami4

     

    Try this as a measure:

     

     

    COUNT OF DAYS =
    VAR START_DATE_ =
        CALCULATE ( MIN ( 'Table'[Date In] ), ALLEXCEPT ( 'Table', 'Table'[Well #] ) )
    VAR END_DATE_ =
        CALCULATE ( MAX ( 'Table'[Date Out] ), ALLEXCEPT ( 'Table', 'Table'[Well #] ) )
    RETURN
        DATEDIFF ( START_DATE_, END_DATE_, DAY )

     

    START_DATE_ computes for the earliest Date In of a Well #. END_DATE_ computes for the latest Date Out of a Well #

    The value being returned is the difference between the two. If you place this measure in a table, you will be seeing the same Count of Days for the same Well # regardless of its dates in and out.