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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Gary_in_Ohio
Regular Visitor

How to filter a dataset with start and end dates

I am looking for a solution to filtering a dataset that contains start and end dates based on a user selecting one date. 

 

Below is a example of the type of data that am working with.

Sample DataSample Data

 

Below is a sample report. 

Report.png

 

In this example, we want to answer the question "Who was working where on June 1, 2022?"

 

I want the users to pick one and only one date.  The users will want to change and rechange this date easily. So, I'd prefer it to be in a slicer.  I want to use only on the data where the start comes on or before the user selected date and the end date is on or after the user selected date.

 

If the users see something incorrect, they will go into the application and make corrections. They will rerun the report and expect see their changes immediately. So, this must work with DirectQuery data.

 

My actual dataset is much more complex.  But this example gets to the heart of the issue.

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @Gary_in_Ohio 

You can create a measure like:

filter =
IF (
    MAX ( Location[StartDate] ) <= SELECTEDVALUE ( AsOf[Date] )
        && MAX ( Location[EndDate] ) >= SELECTEDVALUE ( AsOf[Date] ),
    1,
    0
)

Then you can apply this mesaure to the table visual filter pane.

veasonfmsft_0-1668568133051.png

 

Best Regards,
Community Support Team _ Eason

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @Gary_in_Ohio 

You can create a measure like:

filter =
IF (
    MAX ( Location[StartDate] ) <= SELECTEDVALUE ( AsOf[Date] )
        && MAX ( Location[EndDate] ) >= SELECTEDVALUE ( AsOf[Date] ),
    1,
    0
)

Then you can apply this mesaure to the table visual filter pane.

veasonfmsft_0-1668568133051.png

 

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.