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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
brian0782
Helper II
Helper II

Filter table based on less than and greater than date value

I have the following SQL which returns rows based on <= GETDATE() and >= GETDATE()

 

select b.umr
      ,b.inception_date
	  ,b.expiration_date
from binder b
WHERE b.inception_date<=CAST(GETDATE() AS DATE) -- GETDATE() would instead be a single list date slicer 
	AND b.expiration_date>=CAST(GETDATE() AS DATE) -- GETDATE() would instead be a single list date slicer 

 

brian0782_0-1640187903686.png

 

How am I able to achieve this in Power BI? GETDATE() would basically be a single list date slicer

 

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @brian0782 ,

 

First create a calendar table as a slicer:

date_slicer = CALENDAR(MIN('Table'[inception_date]),MAX('Table'[expiration_date]))


and then create a measure to apply to the visual level filter

Measure = IF(SELECTEDVALUE(date_slicer[Date])>=MAX('Table'[inception_date])&&SELECTEDVALUE(date_slicer[Date])<=MAX('Table'[expiration_date]),1,0)

Vlianlmsft_1-1640660428774.png

Enable the "Single select" option

Vlianlmsft_0-1640660370020.png

 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
V-lianl-msft
Community Support
Community Support

Hi @brian0782 ,

 

First create a calendar table as a slicer:

date_slicer = CALENDAR(MIN('Table'[inception_date]),MAX('Table'[expiration_date]))


and then create a measure to apply to the visual level filter

Measure = IF(SELECTEDVALUE(date_slicer[Date])>=MAX('Table'[inception_date])&&SELECTEDVALUE(date_slicer[Date])<=MAX('Table'[expiration_date]),1,0)

Vlianlmsft_1-1640660428774.png

Enable the "Single select" option

Vlianlmsft_0-1640660370020.png

 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Liang

 

This is almost working but was expecting a 1 in the higlighted row as it falls within the date range.

 

Not quite sure where I'm going wrong:

 

Date Filter = IF(SELECTEDVALUE('Binder Dates'[Date])>=MAX('Binding Authority'[Binder Date From])&&SELECTEDVALUE('Binder Dates'[Date])<=MAX('Binding Authority'[Binder Date To]),1,0)

 

brian0782_0-1641489446128.png

 

Hi @brian0782 ,

 

I guess this may be caused by aggregation or relationship. This row may correspond to more than one date. Try adding a umr column in the table visual and set slicer table as disconnected. If the problem persists, please delete the sensitive data and share a sample pbix.


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, I think this is caused by a many to many bi-directional relationship between Binding Authority and Claim Amounts. We don't have any UMR records in Claim Amounts but we do in Binding Authority.

 

I thought a "Both" filter direction would help handle this.

 

brian0782_0-1641812535925.png

 

I'm not able to attach a sample dashboard. I don't see an optuon to attach a file

 

Hi

 

Apologies for the late reply. This looks like it might work! I'll need to implement it but I can see this working..

 

Will give this a go and get back to you 🙂

 

Thanks

smpa01
Super User
Super User

@brian0782 

SELECTEDVALUE(Calendar[Date])
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors