Forum Discussion

simonchung's avatar
simonchung
Frequent Visitor
4 years ago
Solved

Filter based on date range

Hi PBI Buddies,    I have a sales table simplifed as follow:  There is a date table as a slicer, so that when I select date 2021/09/01, record ID 1 will be displayed in a table visual selec...
  • timg's avatar
    timg
    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