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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
NZCraig
Helper I
Helper I

Filter start and finish date using single date slicer

Hi,

 

I am trying to come up with a filter that shows only table rows that have a start and finish date between the date slicer range on a page. I have found several solutions on the forum that get me close, but I am sure I'm having 'one of those days' for about a week now, and can't figure out the final part. I can use the expression below to get me close, but it shows all rows where the dates overlap the slicer range, and I need it to show exclusively within the slicer range.

Any help would be very much appreciated!!!

 

Craig


Current measure which shows overlapping dates

Date Included =
IF (
FIRSTNONBLANK ( WO[schedstart], 1 ) <= MAX ( 'Date'[Date] ) &&
FIRSTNONBLANK( WO[schedfinish], 1 ) >= MIN ( 'Date'[Date] ),
"Include",
"Exclude"
)
 
Expected result for date range 07 SEP 20 - 13 SEP 20

WO Number

WO schedstart

WO schedfinish

Date Included

Job#1

03/09/20

07/09/20

Excluded

Job#2

08/09/20

10/09/20

Included

Job#3

08/09/20

23/09/20

Excluded

Job#4

09/09/20

09/09/20

Included

Job#5

10/09/20

15/09/20

Excluded

Job#6

11/09/20

17/09/20

Excluded

Job#7

11/09/20

30/11/20

Excluded

Job#8

12/09/20

12/09/20

Included

Job#9

12/09/20

12/09/20

Included

Job#10

13/09/20

14/09/20

Excluded

 
3 REPLIES 3
Greg_Deckler
Super User
Super User

@NZCraig Just to add what @DataInsights great reponse, this solution assumes a disconnected date table, unless I am mistaken, so no relationship between your date table that fuels your slicer and your fact table.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks @DataInsights  and @Greg_Deckler , I am indeed using a related date table.

 

I think typing the question out helped me to reframe my thinking, and I've come up with the follwing, which seems to work, but I'll need to play a bit more and see if I can break it.

 

Date Included =

IF (AND(FIRSTNONBLANK ( WO[schedstart], 1 ) <= MAX ( 'Date'[Date] ),FIRSTNONBLANK ( WO[schedstart], 1 ) >= MIN ( 'Date'[Date] )) &&

    AND(FIRSTNONBLANK( WO[schedfinish], 1 ) >= MIN ( 'Date'[Date] ),FIRSTNONBLANK( WO[schedfinish], 1 ) <= MAX ( 'Date'[Date] )),

    "Include",

    "Exclude"

)

DataInsights
Super User
Super User

@NZCraig, try this measure:

 

Date Included =
VAR vMinDate =
    MINX ( ALLSELECTED ( 'Date' ), 'Date'[Date] )
VAR vMaxDate =
    MAXX ( ALLSELECTED ( 'Date' ), 'Date'[Date] )
VAR vResult =
    IF (
        MAX ( WorkOrders[WO Sched Start] ) >= vMinDate
            && MAX ( WorkOrders[WO Sched Finish] ) <= vMaxDate,
        "Included",
        "Excluded"
    )
RETURN
    vResult

 

The date slicer should be based on the date table. You can add a filter to the table visual that shows only rows where Date Included = "Included".





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

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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