Forum Discussion
Filter based on date range
- 4 years ago
Oke if I understand correctly you always select one date in the slicer, and then want to see all records in the table where that selected date is between the start and end date of that record?
In that case perhaps this will work for you:
1. create a measure which return 1 if the selected date (SELECTEDVALUE()) is between the start and end date of the row
2. place that measure in the filter pane and set it to "value is 1"
3. now, when you select a date in your date slicer, the table will only return the rows where the measure calculation results in a 1.
here is an example of the measure:
SelectedDate = IF ( MIN ( Test[start] ) <= SELECTEDVALUE ( 'Date'[Date] ) && MAX ( Test[end] ) >= SELECTEDVALUE ( 'Date'[Date] ); 1; 0 )and a test where this method seems to work:
Hope that solves it for you,
Tim
Hi Simon,
This should do the trick. Below you will find an example of the end result.
The CONCATENATEX ( VALUES ( TestTable[ID] ); TestTable[ID]; "," ); concats all your column values
The FILTER(.... filters the concatenated values to only include the id's that appear between the start and end date.
ConcatID =
CALCULATE (
CONCATENATEX ( VALUES ( TestTable[ID] ); TestTable[ID]; "," );
FILTER (
'TestTable';
TestTable[DateStart] < SELECTEDVALUE ( 'Calendar'[Date] )
&& TestTable[DateEnd] > SELECTEDVALUE ( 'Calendar'[Date] )
)
)
Hope that helps!
Regards,
Tim
- simonchung4 years agoFrequent Visitor
Thanks so much, really appreciate your help, it's closer.
However it is not my expected result.
In my case, there are 2 visuals, 1 is a slicer and 1 is a table
The Date table is used as a Slicer, when I select "2021/09/07", the Table would show the details of ID 2 & 3 (Mello/400, Cello/900 etc...)
When I select "2021/09/08" or "2021/09/09", the Table would show the details of ID 2 to 5 (Mello..Cello.. Gello.. Kello...)
So on...- timg4 years agoSolution Sage
Oke if I understand correctly you always select one date in the slicer, and then want to see all records in the table where that selected date is between the start and end date of that record?
In that case perhaps this will work for you:
1. create a measure which return 1 if the selected date (SELECTEDVALUE()) is between the start and end date of the row
2. place that measure in the filter pane and set it to "value is 1"
3. now, when you select a date in your date slicer, the table will only return the rows where the measure calculation results in a 1.
here is an example of the measure:
SelectedDate = IF ( MIN ( Test[start] ) <= SELECTEDVALUE ( 'Date'[Date] ) && MAX ( Test[end] ) >= SELECTEDVALUE ( 'Date'[Date] ); 1; 0 )and a test where this method seems to work:
Hope that solves it for you,
Tim
- simonchung4 years agoFrequent Visitor
😍😍😍It works perfectly, thank you so much!
As I will receive files daily and accumulate them, but most of the data are repeated
This action can help saving many file sizes.