Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Filter based on date range in another table

I have a table of data that looks something like this: Bug Title Created Date Closed Date Project Bug 1 1-1-2000 1-30-2000 Project 1 Bug 2 1-5-2000 1-25-2000 Project 1 Bug 3 1-...
  • v-lid-msft's avatar
    6 years ago

    Hi Anonymous ,

     

    We can create a calculated table contain all the possible date first (ignore this step if you already have such one):

     

     

    DateTable =
    CALENDAR ( MIN ( 'Table'[Created Date] ), MAX ( 'Table'[Closed Date] ) )

     

     

    Then we create a measure to count the number:

     

     

    BugsCount = 
    SUMX (
        'Table',
        COUNTX (
            FILTERS ( 'DateTable'[Date] ),
            IF (
                [Date] >= 'Table'[Created Date]
                    && [Date] <= 'Table'[Closed Date],
                1,
                BLANK ()
            )
        )
    )

     

     

    Or

     

     

    BugsCount =
    COUNTX (
        'Table',
        IF (
            SELECTEDVALUE ( 'DateTable'[Date] ) >= 'Table'[Created Date]
                && SELECTEDVALUE ( 'DateTable'[Date] ) <= 'Table'[Closed Date],
            1,
            BLANK ()
        )
    )

     

     

     


    BTW, pbix as attached.

     

    Best regards,

    Community Support Team _ Dong Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.