Forum Discussion
Mafesa_Sasol
3 years agoFrequent Visitor
Finding the difference between two dates in different rows
Hi, I would really appreciate any assistance. I am trying to find the difference between the Start and End Date but in different rows and different columns. For example, in the attached data table, I...
- Anonymous3 years ago
Hi mafesa sasol,
Please find the code :
Standby Date =VAR enddate = Standby[End Date]VAR startdate = Standby[Start Date]VAR minstartdate =CALCULATE (MIN ( Standby[Start Date] ),FILTER ( ALL ( Standby ), Standby[Start Date] > startdate ))VAR result =DATEDIFF ( enddate, minstartdate, DAY )RETURNresult
Mafesa_Sasol
3 years agoFrequent Visitor
Hi Anonymous Yes it is a calculated column. I have attached your code as:
Standby Date = var endddate = Standby[End Date]
var finddate = CALCULATE(MIN(Standby[End Date]), Standby[End Date]> endddate)
var datebeg = Standby[Start Date]
return
datediff(datebeg,finddate,DAY)
In this case, the column name is Standby Date. However, I am getting the calculated column with blanks all the way.
A snapshot of the column is attached below:
The first Column is the Difference of the number of days bewteen the Start Date column. However I need the difference bewteen the Start Date and End date diagonally. For example, the number of days between the Start Date, Monday March 21, 2022 and the End Date Sunday, March 6, 2022.
- Anonymous3 years agoNot applicable
Hi mafesa sasol,
Please find the code :
Standby Date =VAR enddate = Standby[End Date]VAR startdate = Standby[Start Date]VAR minstartdate =CALCULATE (MIN ( Standby[Start Date] ),FILTER ( ALL ( Standby ), Standby[Start Date] > startdate ))VAR result =DATEDIFF ( enddate, minstartdate, DAY )RETURNresult- Anonymous20242 years agoRegular Visitor
Hi, Can you help with excluding weekends (& holidays if possible) in the above solution you have posted?? Thank you!