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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
hamzashafiq
Kudo Collector
Kudo Collector

DateDiff is not working with Applied Slicers

Hi,

 

I want to calculate the DateDiff between two dates for each Serial Number or the values selected from Slicers. But it always calculates based on the complete data, not for the values filtered from the slicer. You can see in the screenshot, it says the total datediff in months are 23 but according to the line chart above, it should show 18. 

 

hamzashafiq_0-1642768529109.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@hamzashafiq , If those are dates remove .date

 

or you can try like

measure =
var _min = minx(allselected(Table), Table[Date])
var _max = maxx(allselected(Table), Table[Date])
return

Datediff(_min, _max, month)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@hamzashafiq , If those are dates remove .date

 

or you can try like

measure =
var _min = minx(allselected(Table), Table[Date])
var _max = maxx(allselected(Table), Table[Date])
return

Datediff(_min, _max, month)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak I removed the .date and it's working now 😀. Have a great day!

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors