Forum Discussion
Get start and end date from Timeline Slicer
Let me keep it simple. I need to find the number of days within a Date range. Say my date range is from 07/01/2016 to 09/30/2016. My table consists of data for certain dates alone:
| Initial Rental Start Date | End Date |
| 7/1/2016 | 7/3/2016 |
| 7/6/2016 | 7/12/2016 |
| 7/15/2016 | 8/14/2016 |
| 8/15/2016 | 9/14/2016 |
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??
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
5 Replies
- v-ljerr-msft
Microsoft Employee
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
- BhaveshPatel
Super User
What do you mean by this.
"but I don't have this {Start Date} and {End Date} available in my table.". Do you want to analyze data for those null dates as well.
Make it bit clear.
Thanks & Regards,
Bhavesh
- Hanuma_SrikiranFrequent Visitor
I mean I don't have 07/01/2016 in my Start Date column and 09/30/2016 in my End Date column. Whenever a user slides over the Timeline slider to select a date range, these two date values changes. I need to use these two dates as an input for my calculated field.
- BhaveshPatel
Super User
It would be better if you use parameters for this purpose. It is dynamic and can adapt to your requirement.
Thanks & Regards,
Bhavesh