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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register 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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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