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
AshDil
Helper V
Helper V

Want to calculate difference between dates entered in Slicer even those records not present in Table

Hi,

I have the date range slicer as follows,

AshDil_0-1638243416264.png

In date slicer I have selected Start date = 5/1/2017 and End date  = 3/16/2018. As these dates are not present in my fact table I'm getting difference as blank.

Please help me to do it.

Thanks,

AshDil.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @AshDil 

If you want to calculate the day differences by dates in your date between slicer, you need to use min and max function to catch the start date and the end date in your data model. So you need to create a date table by dax, and relate two tables by date column, then create slicer by date column in date table.

Date Table:

Date = CALENDARAUTO()

Relationship:

1.png

Measure:

DayDiff = 
VAR _RangeStart = MIN('Date'[Date])
VAR _RangeEnd = MAX('Date'[Date])
RETURN
DATEDIFF(_RangeStart,_RangeEnd,DAY)

Result is as below.

2.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@AshDil , Ideally you should use a date table wih all the needed dates and join that with you table

 

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

datediff(_min, _max, day)

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

Hi @amitchandak ,

 

I have tried using above formula but getting large difference.

For eg, I have selected Start date = 11/22/2021 and End Date = 11/30/2021 my expected output is 8, but getting difference as 1461.

Please help me do it.

Thanks,

Ashdil

Anonymous
Not applicable

Hi @AshDil 

If you want to calculate the day differences by dates in your date between slicer, you need to use min and max function to catch the start date and the end date in your data model. So you need to create a date table by dax, and relate two tables by date column, then create slicer by date column in date table.

Date Table:

Date = CALENDARAUTO()

Relationship:

1.png

Measure:

DayDiff = 
VAR _RangeStart = MIN('Date'[Date])
VAR _RangeEnd = MAX('Date'[Date])
RETURN
DATEDIFF(_RangeStart,_RangeEnd,DAY)

Result is as below.

2.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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 Kudoed Authors