Forum Discussion

peter_jak's avatar
peter_jak
Regular Visitor
5 years ago
Solved

Filter daterange

Hello

Sorry if this has been already answered, but I could not find the answer easily.

 

I have two tables. Ther is no relationship between them.

I would like to filter rows from Table2 where the Date value is between From and To values selected in Table1

Table1

FromTo
24.Aug.202030.Sept.2020
23.July.202023.August.2020

 

Table2

ProjectInvoiceDate
Proj1$1025.Aug.2020
Proj2$5029.Sept.2020
Proj1$2022.Aug.2020

 

Once the user selects a row in Table1 then the only rows from Table2 within From/To Range are displayed.

 

  • user selects row: Table1, From:24.Aug.2020,To:30.Sept.2020
  • Only the Dates 25.Aug.2020 and 29.Sept.2020 are displayed

What meassure should I create to achieve this?

 

Thank you

Peter

  • Hi peter_jak ,

    You need to create a measure and add it to the filter panel as a condition.

    Please use this measure:

    IsSelectedPeriod = 
    VAR __StartDate = MIN(Table1[From])
    VAR __EndDate = MAX(Table1[To])
    VAR __ProjectDate = MAX(Table2[Date])
    
    RETURN
    IF(
        __ProjectDate >= __StartDate
        && __ProjectDate <= __EndDate,
        1,
        0
    )

     and add it to the visual filter for Table2:

    The result:



    _______________
    If I helped, please accept the solution and give kudos! 😀

2 Replies

  • lkalawski's avatar
    lkalawski
    Icon for Resident Rockstar rankResident Rockstar

    Hi peter_jak ,

    You need to create a measure and add it to the filter panel as a condition.

    Please use this measure:

    IsSelectedPeriod = 
    VAR __StartDate = MIN(Table1[From])
    VAR __EndDate = MAX(Table1[To])
    VAR __ProjectDate = MAX(Table2[Date])
    
    RETURN
    IF(
        __ProjectDate >= __StartDate
        && __ProjectDate <= __EndDate,
        1,
        0
    )

     and add it to the visual filter for Table2:

    The result:



    _______________
    If I helped, please accept the solution and give kudos! 😀

  • peter_jak's avatar
    peter_jak
    Regular Visitor

    Thank you very much for quick and good solution. It works