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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DateDiff depending on Date Slicer

I've got rows that have columns [FromTime] and [ToTime], so I'm try to create a column that shows DATEDIFF between these 2 columns, but I also want the DATEDIFF to take into account the slicer which is based off the [FromTime] column.

 

So if I have a [FromTime] of April 1, and a [ToTime] of April 10, but my slicer is filtering [FromTime] to show dates between April 8-12, then the DATEDIFF will only show 2 days (April 8 - April 10)

 

Here's some more examples of how it should calculate:

Date Filter[FromTime][ToTime]DATEDIFF
April 1- April 5April 1April 105
March 28 - April 5April 1April 105
April 9 - April 13April 1April 101

 

Hope this makes sense!

 

Thanks everyone!

1 REPLY 1
FreemanZ
Super User
Super User

hi @Anonymous 

Supposing you have two tables like:

FreemanZ_0-1682169063931.png

FreemanZ_1-1682169079999.png

they are not related. 

 

1) try to plot a slicer with Dates[Date] column

2) try to plot a table visual with Data[From], Data[To] and a measure like:

Datediff = 
DATEDIFF(
    MAX(MAX(Data[From]),MIN(Dates[Date])),
    MIN(MAX(Data[To]),MAX(Dates[Date])),
    DAY
)+1

 

it worked like:

FreemanZ_3-1682169262225.png

FreemanZ_4-1682169278304.png

FreemanZ_5-1682169329286.png

 

p.s. calculated columns are not responsive to slicer or any report visuals, so table visual with meausre is used here. 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.