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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
tariktik
New Member

Using date slicer on a measure

First post here for Power BI newbie.

 

I have a table with a "Start Date", "End Date" columns among many other columns and I created a column to compute the duration between those two dates.

 

On my report, I added a slicer with Style "Between" based on the "Start Date" column.  If I select a date range, how can I exclude the records where the "End Date" is beyond the selected date range?  To illustrate, let's say I have the following records:

 

Start DateEnd DateDuration
1/1/20231/10/20239 days
1/4/20231/8/20234 days
1/2/20231/12/202310 days
1/3/20231/9/20236 days

 

If I set my slicer (based on Start Date) to 1/1/2023 - 1/10/2023, how can I exclude the 3rd record since the record is technically still not complete during the time period?

 

I am expecting to get only the following records:

 

Start DateEnd DateDuration
1/1/20231/10/20239 days
1/4/20231/8/20234 days
1/3/20231/9/20236 days

 

Thanks in advance for the help.

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @tariktik 

 

I recommend that you create a date table in the model to have continuous dates and create a relationship from this date table's "Date" column to the "Start Date" column in the original table. Use date table's "Date" column in your slicer. This could avoid a scenario that some dates do not exist in the "Start Date" column in the original table, which would make the filter result not accurate. 

Date = CALENDAR(MIN('Table'[Start Date]),MAX('Table'[End Date]))

Then you can create the following measure

Flag = IF(SELECTEDVALUE('Table'[End Date]) <= MAX('Date'[Date]), 1, 0)

Add this measure on the table visual as a filter and set it to show items when value is 1. This will exclude the records you don't want from the table visual. 

vjingzhang_0-1679380087919.png

The sample file is attached at bottom. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @tariktik 

 

I recommend that you create a date table in the model to have continuous dates and create a relationship from this date table's "Date" column to the "Start Date" column in the original table. Use date table's "Date" column in your slicer. This could avoid a scenario that some dates do not exist in the "Start Date" column in the original table, which would make the filter result not accurate. 

Date = CALENDAR(MIN('Table'[Start Date]),MAX('Table'[End Date]))

Then you can create the following measure

Flag = IF(SELECTEDVALUE('Table'[End Date]) <= MAX('Date'[Date]), 1, 0)

Add this measure on the table visual as a filter and set it to show items when value is 1. This will exclude the records you don't want from the table visual. 

vjingzhang_0-1679380087919.png

The sample file is attached at bottom. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Thank you very much v-jingzhang.

RichardOfSydney
Regular Visitor

Use power pivot - create a measure which filters based on start and end date.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.