Forum Discussion

Nicolas_H's avatar
Nicolas_H
Frequent Visitor
3 years ago
Solved

Filtering data between validity periods from an input parameter

Hello,   I need to filter some data with a refence date (which is entered by the user) using 2 dates (start date & end date) that define a validity period.   My table contains :   I want ...
  • DataInsights's avatar
    DataInsights
    3 years ago

    Nicolas_H,

     

    You could use SWITCH to determine which table is applicable:

     

    Visual Filter = 
    VAR vSelectedDate =
        SELECTEDVALUE ( 'Calendar'[Date] )
    VAR vResult =
        SWITCH (
            TRUE,
            ISINSCOPE ( FactTable[Start Date] ),
                SUMX (
                    FactTable,
                    IF (
                        vSelectedDate > FactTable[Start Date]
                            && vSelectedDate < FactTable[End Date],
                        1
                    )
                ),
            ISINSCOPE ( FactTable2[Start Date] ),
                SUMX (
                    FactTable2,
                    IF (
                        vSelectedDate > FactTable2[Start Date]
                            && vSelectedDate < FactTable2[End Date],
                        1
                    )
                )
        )
    RETURN
        vResult