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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bernate
Advocate I
Advocate I

Filter Date Table by Oldest Date in Other Table

Hello all, 

 

The date table I'm using in my report goes back to 2015, but the table with data I'm using has an earliest date of 2018. I want to automatically filter the date table to the earliest date (2018) so that the extra years don't show up in slicers. 

 

I tried to follow the steps in the link below, but Power Query would get stuck on this step (loading for a long time with no result)

 

Table.SelectRows(#"Changed Type", each List.Contains(#"Table 2"[BuildingID],[BuildingID]))

 Solved: Filtering table based on another table conditions ... - Power Platform Community (microsoft....

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Get the earliest date from the data table (using List.Min(...))
Replace the condition in Table.SelectRows to keep the rows where the date is higher than this.

View solution in original post

5 REPLIES 5
HotChilli
Super User
Super User

Get the earliest date from the data table (using List.Min(...))
Replace the condition in Table.SelectRows to keep the rows where the date is higher than this.

Okay so in my Date table query I added 

 

let
StartDate = List.Min(#"FactTable"[Date]),
EndDate = List.Max(#"FactTable"[Date]),

 

but I'm not sure how to change the Table.SelectRows statement to keep the rows in between those dates. I have:

 

Table.SelectRows(#"Added Custom1", each List.Contains(#"DateTable"[CalendarDt],StartDate))

Oh got it now, I did the following:

 

= Table.SelectRows(#"Added Custom1", each [DtKey] >= (StartDate) and [DtKey] <= (EndDate))

HotChilli
Super User
Super User

Table.SelectRows can be slow depending on the condition applied. Why don't you limit the date table at creation time based on the max date in the Fact table? Create your own date table with CALENDAR in Dax or a Power Query calendar creation (lots available online)

I don't want to create a date table because I'm using one that has company holidays and closures factored in. 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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