Forum Discussion
Days Remaining Calculation
- Anonymous9 years ago
Awesome. Actually needed a MIN not MAX, as I was trying to get a day count between today and end date. If end date is after today then 0.
= MIN ( 1 * ( Today ( ) - YourTable[EndDate] ) , 0)
Thanks - this was extremely helpful!
- 9 years ago
Anonymous
If [End Date] > Today ( ) Then 0 Else 1 * ( Today ( ) - YourTable[EndDate] ) is equivalent to
MAX ( 1 * ( Today ( ) - YourTable[EndDate] ) , 0)
or
- MIN ( 1 * ( YourTable[EndDate] - Today ( ) ) , 0 )
But not to:
MIN ( 1 * ( Today ( ) - YourTable[EndDate] ) , 0)
Hi Anonymous
Do you wish to perform this calculation in a measure or a calculated column ?
You can use DateDiff Function to calculate the number of days between Today and your EndDate.
In a calc. Column:
DateDiff ( YourTable[EndDate] , Today() , DAY)
In a measure, you'll need to wrap your 1st argument into an aggregator such as Min or Max in this case.
- Anonymous9 years agoNot applicable
I believe I need it as a column. Following your instructions I receive an error:
Too few arguments were passed to the RELATED funtion. The minimum argument count for the functions is 1.
Not sure what this means.
- Datatouille9 years agoSolution Sage
Anonymous
Why are you using Related function here ? Haven't mentioned it in my reply.
- Anonymous9 years agoNot applicable
Sorry. Corrected by creating New Column.
Now I get a meesage that the start date cannot be greater than the end date. In the case of this data I have both a start date and an end date, and the dataset itself is aggregated by day.
Simply meaning that the dataset will have information from the past, present and future. End dats could be before Today, so I would have expected 0 Days Remaining. If the if I am between today and the end date, I would expect a day count remaining and lastly if the start date is greater than today, then a count of days between start date and end date.
Thanks again for the help.