Power BI: How to Calculate Days Between Two Dates


You can use the following syntax in DAX to calculate the number of days between two dates in Power BI:

Days Between = 1 * my_data[End Date] - my_data[Start Date]

This particular example creates a new column named Days Between that contains the number of days between the date in the End Date column of a table and the date in the Start Date column.

The following example shows how to use this syntax in practice.

Example: How to Calculate Days Between Two Dates in Power BI

Suppose we have the following table in Power BI named my_data that contains information on the start date and end date for various tasks at some company:

Suppose that we would like to create a new column that contains the number of days between the dates in the Start Date and End Date columns.

To do so, click the Table tools tab and then click the New column icon:

Then type the following formula into the formula bar:

Days Between = 1 * my_data[End Date] - my_data[Start Date]

This will create a new column named Days Between that contains the number of days between the dates in the Start Date and End Date columns:

Power BI calculate days between two dates

From the output we can see:

  • There are 29 days between 1/1/2024 and 1/30/2024.
  • There are 0 days between 1/5/2024 and 1/5/2024.
  • There are 4 days between 1/15/2024 and 1/19/2024.

And so on.

Note: In the formula we multiplied by 1 to prevent the output from being shown as a date.

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

How to Add Months to Date in Power BI
How to Add Days to Date in Power BI
How to Find Max Date in Power BI

Leave a Reply

Your email address will not be published. Required fields are marked *