Syntax
DATEDIFF(<start_date>, <end_date>, <interval>)
Tutorial with example
EXAMPLE 1
In today’s video, I will show you how to calculate the difference between two dates using DATEDIFF.
I also show you how to overcome the issue when the start date is larger than the end date.
Download example file:
Link to demo file here.
EXAMPLE 2
In today’s video we will deconstruct a measure that was created by a microsoft employee in the Power BI community:
Link to the Power BI community post: https://community.powerbi.com/t5/Desktop/Calculate-duration-based-on-dates-in-different-rows/td-p/58886
In this video we will go also through the functions:
05:56 LOOKUPVALUE
09:12 DATEDIFF and
How to calculate the difference between two dates in the same column in Power BI.
EXAMPLE 3
Do you know how to calculate the difference between dates when both are in the same column?
One example of when this is needed is when you are working with subscription based services. If you want to calculate how many dates go between users changing subscriptions, this DAX measure will help you.
EXAMPLE 4
When the custom date filter in Power BI doesn’t do what you need, how you create your own? What if you need to do it by week?
Download example files:
Download the pbix and excel file here.
Remarks
An error is returned if start_date is larger than end_date.
Let us know your thoughts...