Forum Discussion
DATEDIFF within IF
Please could someone tell me why this doesn't work?
=if([status]="Closed",
DATEDIFF([date_entered],[date_closed],DAY),
"Not Closed"
)
I wish to calculate the number of days between the date_entered column and the date_closed column when the status column = Closed.
Thanks
5 Replies
- JorgePinhoSolution Sage
Is that a measure or a new column?
If it is a measure you have to use something like: DATEDIFF(MAX([date_entered]),MAX([date_closed]),DAY)
- AnonymousNot applicable
This is a new column.
- JorgePinhoSolution Sage
Can you show the error that appears please?
- AnonymousNot applicable
Looking at this a little deeper, I believe there is a problem with the source data and it not being in Date format.
I've tried cleaning up the date data but that produces a different error.
- v-yueyunzh-msftCommunity Support
Hi , Anonymous
If you use the DATEDIFF() function, you must check the first two parameters are "Date" or "Date/Time" format.
If it's not a date format, you can modify your date format in Power Query Editor.
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly