Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Count values between dates

Hi all!  I need a DAX measure to count items between dates, example:   item start end A 01/01/2022 03/01/2022 B 05/01/2022 10/01/2022 C 04/01/2022 06/01/2022 D 02/01/2022 ...
  • v-zhangti's avatar
    4 years ago

    Hi, Anonymous 

     

    You can try the following methods.

    Table:

    calendar = CALENDAR(MIN('Table'[start]),MAX('Table'[end]))

    Measure:

    quantity item =
    CALCULATE (
        COUNT ( 'Table'[item] ),
        FILTER (
            ALL ( 'Table' ),
            [start] <= SELECTEDVALUE ( 'calendar'[Date] )
                && [end] >= SELECTEDVALUE ( 'calendar'[Date] )
        )
    )
    

    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.