Forum Discussion
Get start and end date from Timeline Slicer
- 9 years ago
Now if I am to select date range from 07/01/2016 to 09/30/2016 in the Time Slider and also have to find the difference of these two dates (in days), but I don't have this {Start Date} and {End Date} available in my table. Is there any way to do this or a work around??You can use MIN and MAX function to get the Start Date and End Date from Timeline Slicer. See my sample below.
I assume you have Date table called MyDateTable contains a date column which is used by Timeline Slicer like below.
And MyTestFactTable like below.
Then should be able to use the formula below to get the Start Date and End Date from Timeline Slicer, and calculate the difference of them in days.
StartDate = CALCULATE ( MIN ( MyDateTable[Date] ), ALLSELECTED ( MyDateTable[Date] ) ) EndDate = CALCULATE ( MAX ( MyDateTable[Date] ), ALLSELECTED ( MyDateTable[Date] ) ) DateDifff = CALCULATE ( DATEDIFF ( MIN ( MyDateTable[Date] ), MAX ( MyDateTable[Date] ), DAY ), ALLSELECTED ( MyDateTable[Date] ) )And use the formula below to calculate the utilization.
Utilization = DATEDIFF ( MIN ( MyTestFactTable[Initial Rental Start Date] ), MAX ( MyTestFactTable[End Date] ), DAY ) / CALCULATE ( DATEDIFF ( MIN ( MyDateTable[Date] ), MAX ( MyDateTable[Date] ), DAY ), ALLSELECTED ( MyDateTable[Date] ) )Regards
Now if I am to select date range from 07/01/2016 to 09/30/2016 in the Time Slider and also have to find the difference of these two dates (in days), but I don't have this {Start Date} and {End Date} available in my table. Is there any way to do this or a work around??
You can use MIN and MAX function to get the Start Date and End Date from Timeline Slicer. See my sample below.
I assume you have Date table called MyDateTable contains a date column which is used by Timeline Slicer like below.
And MyTestFactTable like below.
Then should be able to use the formula below to get the Start Date and End Date from Timeline Slicer, and calculate the difference of them in days.
StartDate = CALCULATE ( MIN ( MyDateTable[Date] ), ALLSELECTED ( MyDateTable[Date] ) )
EndDate = CALCULATE ( MAX ( MyDateTable[Date] ), ALLSELECTED ( MyDateTable[Date] ) )
DateDifff =
CALCULATE (
DATEDIFF ( MIN ( MyDateTable[Date] ), MAX ( MyDateTable[Date] ), DAY ),
ALLSELECTED ( MyDateTable[Date] )
)And use the formula below to calculate the utilization.
Utilization =
DATEDIFF (
MIN ( MyTestFactTable[Initial Rental Start Date] ),
MAX ( MyTestFactTable[End Date] ),
DAY
)
/ CALCULATE (
DATEDIFF ( MIN ( MyDateTable[Date] ), MAX ( MyDateTable[Date] ), DAY ),
ALLSELECTED ( MyDateTable[Date] )
)
Regards