Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Filter Activities between a date range

Hi Everyone,    I have a table with the list of activities with start date and finish date. Please refer the table below:     I'm trying to create a lookahead schedule. For example, I wan...
  • v-alq-msft's avatar
    6 years ago

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

     

    Table:

     

    Calendar(a calculated table):

    Calendar = CALENDARAUTO()

     

    There is no relationship between two tables. You may create a measure as below.

    Visual Control = 
    var _min = CALCULATE(MIN('Calendar'[Date]),ALLSELECTED('Calendar'))
    var _max = CALCULATE(MAX('Calendar'[Date]),ALLSELECTED('Calendar'))
    var tab = 
    SUMMARIZE(
        'Table',
        'Table'[Activity],
        'Table'[Start],
        'Table'[Finish],
        "flag",
        IF(
            NOT(
                OR(
                    [Start]>_max,
                    [Finish]<_min
                )
            ),
            1,0
        )
    )
    return
    SUMX(
        tab,
        [flag]
    )

     

    Then you need to put the measure in the visual level filter and use the 'Date' column from 'Calendar' table to filter the result.

     

     

    Best Regards

    Allan

     

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

     

  • jdbuchanan71's avatar
    jdbuchanan71
    6 years ago

    Hello Anonymous 

    We can modify the measure a bit to turn off the relationship between the Dates table and the 'Activity Status' table just when doing the [Active Count] using CROSSFILTER:

    Active Count No Join = 
    CALCULATE(
        VAR _Start = FIRSTDATE ( DATES[Date] )
        VAR _End = LASTDATE ( DATES[Date] )
        RETURN
        CALCULATE(
            COUNTROWS('Activity Status'),
            'Activity Status'[Start] <= _End,
            'Activity Status'[End] >= _Start
        )
        ,CROSSFILTER('Activity Status'[Start],DATES[Date],None)
    )

    In my sample file the date table is linked and the normal count on catches the joined month, like you are seeing.  The updated meassure ignores the link when calculating so it returns on the months from start to finish. 

    In the screenshot below the date slicer is filtering only the table below it and you can see that my date range is set to Feb 2019 and the table is showing all projects where the active period crosses Feb-2019.

    I have attached my sample file for you to look at.