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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors