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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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)

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)

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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