Forum Discussion
Filter Activities between a date range
- 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.
- 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.
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.
This is great. But I already have a calendar table connected to my activity table.
Also, It would be greatly helpful if I can get the help to filter the activities that are either starting in June 2020 or finishing in June 2020. Using the date slicer for June 01, 2020 to June 30, 2020 does not capture the activties that are started before June 2020 or will be finishing after June 2020.
If needed, I can share my file with you and that way it would be easy for you to figure out.
Thanks and Regards,
Nilesh Jain
- jdbuchanan716 years agoSuper User
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.
- Anonymous6 years agoNot applicable
Genius.
I really appreciate your efforts to put together the sample sheet.
Thanks again!
Regads,
Nilesh Jain