Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Nicolas_H
Frequent Visitor

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 :

Nicolas_H_3-1680008512946.png

 

I want to select a date (idealy by pick in a calendar object) and filter the line where :

[Start Date] < "Selected Date" < [End Date]

 

for example :

if i pick 20/12/2022, i will filter this line

Nicolas_H_2-1680008497454.png

 

 

Also, i have others tables where i want to reproduce this feature, so i would like to use only one date (from my calendar table ?) to drive all the filters on validity periods.

 

Nicolas_H_5-1680009256424.png

 

 

Can someone please help me ?

 

Thanks.

Nicolas

 

1 ACCEPTED SOLUTION

@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




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
DataInsights
Super User
Super User

@Nicolas_H,

 

Create the measure below and use it as a visual filter ("is greater than 0"). The Calendar table does not have a relationship with the fact table. The date slicer uses the Calendar table.

 

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

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for your answer, it's a great step for me 🙂

So if i understant well, i have to create a measure to filter each table with validity periods ?

And is there a mean to drive all these filters with only one "general filter" ?

 

Because if i've got 20 tables with validity periods, when i want to cross all the data in one report table, i 'd prefer use 1 filter rather than 20...

 

Thanks

Nicolas

@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




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I think i can do with that

Thanks for the help

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.