Forum Discussion
Selecting the time passed from a date
- 4 years ago
Hi, Anonymous
Create a calendar table and use the date of the calendar table as a slicer. And control the slicer to single selection.Then to create a measure as follows:
Measure 3 = var _datediff=DATEDIFF(MAX('Table'[Date]),SELECTEDVALUE('calendar'[Date]),DAY) var _if=IF(HASONEVALUE('calendar'[Date]),_datediff,"Only one date can be required") return _ifResult:
Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
We´re getting very close. The only thing which is failing (i think) is the parameter value. Instead of a number, it should be a date, right? Or at least, a value which adds X period of time to the first date in the DATEDIFF function.
For example, I select "2 months" in a visualization, the DATEDIFF is made between the dates column and that date 2 months after. If the date is 03/05/2011, the DATEDIFF should be calculated between that date, 03/05/2011, and 03/07/2011, that same date two months after.
Hi, Anonymous
Create a calendar table and use the date of the calendar table as a slicer. And control the slicer to single selection.
Then to create a measure as follows:
Measure 3 =
var _datediff=DATEDIFF(MAX('Table'[Date]),SELECTEDVALUE('calendar'[Date]),DAY)
var _if=IF(HASONEVALUE('calendar'[Date]),_datediff,"Only one date can be required")
return _if
Result:
Please refer to the attachment below for details. Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.