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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
taylorpeter55
Frequent Visitor

Check if Date from a slicer is within a range of two date fields

Hi,

 

I have a slicer in my dashboard as outlined in red below and a table with Range Start and End Dates (Second screenshot). 

 

Does anyone know if there is there a way of filtering the rows in my table based on whether the Range selected in the slicer has any crossover with the Start & End Dates range in my table? 

taylorpeter55_0-1721050077197.png 

 

In other words, all but the row highlighted in yellow would be included in the filter. The yellow row would be excluded because the Project ended before the lower date selected in the slicer.  

taylorpeter55_4-1721050364327.png

 

I've trawled through the forum and although there are many similar discussions, i've not found one that works for my particular predicament. 

 

Thank you in advance for any assistance you can provide. 

Pete

 

 

 

 

 

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @taylorpeter55 

 

NOTE: You posted in the PQ fourm but you can't do this in PQ. If you are using slicers you need to use DAX. I moved this to the Desktop forum.

 

Download example PBIX file

 

I've used a disconnected Date Table for this.  The slicer is gettign its dates from this table.

 

Get the earliest (MIN) date from the slicer

 

MinStartDate = CALCULATE(MIN('DateTable'[Date]))

 

 

and the latest (MAX) date from the slicer

 

MaxEndDate = CALCULATE(MAX('DateTable'[Date]))

 

 

Create a measure that checks for overlap between the dates selected in the slicer, and your data.  If there is, assign a value of 1, else 0.

 

ShowRecord = IF(SELECTEDVALUE('DataTable'[Start Date]) > [MaxEndDate] || SELECTEDVALUE('DataTable'[End Date]) < [MinStartDate], 0, 1)

 

 

The logic here is that a project End Date must be after its Start Date.  So you just need to check if the Start Date is later than the max date, and if the End Date is earlier than the min date.

 

Use this measure as a filter on your table.  Only shows records where the measure is 1.

 

showdates.png

 

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar problem in the attached file.

Hope this helps.

Ashish_Mathur_0-1721098875244.png

 

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
taylorpeter55
Frequent Visitor

Hi @Ashish_Mathur@PhilipTreacy 

 

I've had a look at your solutions and they are both very similar - and work great :-). Thanks so much. 

 

I do have a further question if you don't mind please. 

 

The date table that I have created is based on the date range within my single data source (let's call it data source A).

 

However, when trying to apply this to my data, I realised that I have two different data sources, both with different date columns. 

 

Is it possible to use the slicer created in your example above to filter on the separate date columns in the two different date sources?  

 

The reason I ask is that in the below screenshot, the 'active projects in portfolio' card is from data source A (Start Date and End Date in previous example we worked), however, the 'Using Automation' card is from data source B - this data source only has one date column called Execution Date. 

 

taylorpeter55_0-1721198294972.png

I was wondering if it is possible to use the Min/Max dates from your earlier solution to count rows in data set B where the Execution Date is between the Min/Max dates?

Hopefully i've explained that ok but please let me know if any further questions. 


Thanks again for your help - I really appreciate it. 


Pete 

 

@Ashish_Mathur @PhilipTreacy After a little bit more digging i found the Sync Slicer option in desktop. Problem solved 🙂

 

Thanks so much for your help. 

Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar problem in the attached file.

Hope this helps.

Ashish_Mathur_0-1721098875244.png

 

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur Thanks so much for sharing your solution. I will review this today and report back 🙂

PhilipTreacy
Super User
Super User

Hi @taylorpeter55 

 

NOTE: You posted in the PQ fourm but you can't do this in PQ. If you are using slicers you need to use DAX. I moved this to the Desktop forum.

 

Download example PBIX file

 

I've used a disconnected Date Table for this.  The slicer is gettign its dates from this table.

 

Get the earliest (MIN) date from the slicer

 

MinStartDate = CALCULATE(MIN('DateTable'[Date]))

 

 

and the latest (MAX) date from the slicer

 

MaxEndDate = CALCULATE(MAX('DateTable'[Date]))

 

 

Create a measure that checks for overlap between the dates selected in the slicer, and your data.  If there is, assign a value of 1, else 0.

 

ShowRecord = IF(SELECTEDVALUE('DataTable'[Start Date]) > [MaxEndDate] || SELECTEDVALUE('DataTable'[End Date]) < [MinStartDate], 0, 1)

 

 

The logic here is that a project End Date must be after its Start Date.  So you just need to check if the Start Date is later than the max date, and if the End Date is earlier than the min date.

 

Use this measure as a filter on your table.  Only shows records where the measure is 1.

 

showdates.png

 

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil, Thanks so much for sharing your solution and the detailed description. I will review this today and see if I can apply this to my dashboard. I'll let you know how i get on 🙂

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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