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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure to calculate the number of days between two dates in a date slider

I have a date slicer, say values of 1/1/17 to 1/21/17.  I would like a simple measure of the number of days between those two dates (i.e. 20).  I want to used that measure to create a number of visuals based on the number of days selected in the slider.  If it's 1/1/16 to 1/2/17, I want the measure to return 366 days.  Hope this makes sense.  Seems like it should be an easy one.  Appreciate your help!!

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @Anonymous

 

Please try the following calculated measure. Just substitute the table/date column you are using in your slicer.

 

Days Between = DATEDIFF(
					MIN('Table'[Date]),
					MAX('Table'[Date]),
					DAY
					)

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Phil_Seamark
Employee
Employee

Hi @Anonymous

 

Please try the following calculated measure. Just substitute the table/date column you are using in your slicer.

 

Days Between = DATEDIFF(
					MIN('Table'[Date]),
					MAX('Table'[Date]),
					DAY
					)

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hello,

 

How about returning just business days M-F

 

Thanks

Hi @chaddruck

 

One way is to keep a column in your Date Table that carries just 1's and 0's.  Set weekend values (and holidays if you can) to 0. That way you can just SUM the column between the dates you care about and that should hopefully give you the number you need.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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