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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Filter Data based on Date ranges

i have a table that  contains failure information recorded which includes  Date_Failure_End(which is the date the failure item was fixed) and an Date_Failure_Start(date when the failure item started) 

 

I also have a Date table that just has date items from 01-01-2006 till Current date.

 

Both of these tables are linked and the relationship is by the Date_Failure_Start from the Failure Table

 

i have a Date Slicer filter that i would like to use to filter the Failure Table to only show items where the date is in the range of start_date and end_date and for items that do not have end_dates(or end_date is Null) i would like the range to be based on the current_date 

 

i'm thinking that this could be solved by creating a measure that assigns the value "1" for each item if the slected date is in the range of the start_date and the end_date or in the event where there is no end_date the check is carried out if the selected date is in between the start_date and the  current_date. Finally assigns "0" to the other items that do not satisfy the condition

 

 

i'm not very good at DAX queries especially around nested if statements , i was wandering if anyone could help

 

powerbidaxquery.PNG

Measure = 
VAR current_date = 
MIN( 'Date Table'[Date])
VAR start_date = 
MIN( 'NPTTest'[DATE_FAILURE_START])

VAR end_date = 
MIN( 'NPTTest'[DATE_FAILURE_END])

RETURN
    IF(
         (
            current_date >= start_date
        )
        && 
        (
            current_date <= end_date
         ),1,0 
        
    )

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion


Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365

 

Also, you might find this article of interest:

See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion


Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365

 

Also, you might find this article of interest:

See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

This is great, it look like exactly what i need.

 

Thanks you so much

 

 

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.