Power BI: How to Filter Between Two Dates


You can use the following syntax in DAX to filter a table for rows where a date column is between two specific dates:

filtered_data =
CALCULATETABLE (
    'my_data',
    DATESBETWEEN ('my_data'[Date], DATE(2022, 5, 1), DATE(2023, 8, 20))
)

This particular example creates a new table named filtered_data that contains only the rows from the table named my_data where the date in the Date column is between 5/1/2022 and 8/20/2023.

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

Example: How to Filter Between Two Dates in Power BI

Suppose we have the following table in Power BI named my_data that contains information about sales made on various dates at some company:

Suppose we would like to filter the table to only show the rows where the date in the Date column is between 5/1/2022 and 8/20/2023.

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

Then type the following formula into the formula bar:

filtered_data =
CALCULATETABLE (
    'my_data',
    DATESBETWEEN ('my_data'[Date], DATE(2022, 5, 1), DATE(2023, 8, 20))
)

This will create a new table named filtered_data that contains only the rows from the table named my_data where the date in the Date column is between 5/1/2022 and 8/20/2023:

Power BI filter between two dates

To filter using two different dates, simply change the start and end dates within the DATESBETWEEN function in the formula.

Note: You can find the complete documentation for the DATESBETWEEN function in DAX here.

Additional Resources

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

Power BI: How to Use “If Contains” Formula
Power BI: How to Count Distinct Values with Filter
Power BI: How to Create Measure with Multiple Filter Conditions

Leave a Reply

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