Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Transform Data to filter out records based on dates from another table

Hello,

 

I have a table with a large number of records which contains daily snapshots of each item (let's call this table "Historical").  I also have another table which contains two date fields which has a "Start Date" and an "End Date" column for every schedule (let's call this table "Range").

 

Sample data for Range table (the Start Date and End Date usually overlaps but there could be instances when they don't):

Schedule Start Date End Date
A 12/27/2023 1/10/2024
B 1/10/2024 1/24/2024
C 1/24/2024 2/7/2024
D 2/7/2024 2/21/2024

 

The "Historical" table contains a date column (let's just call it "Date") that indicates when the snapshot was taken.  I would like to filter out the records so that it only loads snapshots that were taken on the "Start Date" and "End Date" of the "Range" table and exclude all other daily snapshots so that I can reduce the data refresh time and decrease the table size.

 

It is possible to do this during Transform?

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“Range”

vnuocmsft_0-1710898296019.png

 

"Historical" 

vnuocmsft_1-1710898318759.png

 

Historical = CALENDAR("10/1/2023", "3/20/2024")

 

 

Create a measure. Search for dates in the "Range" range.

 

range_date = 
var _startDate = MIN('Range'[Start Date])
var _endDate = MAX('Range'[End Date])
RETURN 
    CALCULATE(
        SELECTEDVALUE('Historical'[Date]),
        FILTER(
            'Historical', 
            'Historical'[Date] >= _startDate 
            && 
            'Historical'[Date] <= _endDate
        )
    )

 

 

Here is the result.

vnuocmsft_0-1710898504448.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Hi @Anonymous,

 

Thanks for your response.  Appreciate it a lot.  I am actually looking for a way to filter out the data during the load process so that all the records from Historical that does not match the Range table will not be loaded during data refresh.

 

Is there a way to do this?

Anonymous
Not applicable

Hi @Anonymous 

 

If you want to filter the data during the load data phase, you can go to the Power Query editor.

 

This allows you to filter the data before it enters the model.

 

You can set a date range in the Power Query editor to include only data from a specific time period, or exclude unwanted records based on certain criteria.

 

Select the columns you wish to filter and click on the drop down option to find Custom Filtering.

 

vnuocmsft_0-1710982700527.png

 

vnuocmsft_1-1710982730425.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Thanks again @Anonymous but the Power Query filter just lets me input arbitrary dates and not based the value on another table column.  I am not sure if my scenario is even possible.  Thanks again!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.