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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
bol
Frequent Visitor

Filter a page with date less than max date from Fact table

Hello,

 

I am new to DAX, just received a two days training overall on PBI after a few months struggling for basically anything related to DAX.

 

My Data model contains several fact tables. One table with 'FactA'[Date] data in 2024, another with 'FactB'[Date] only up to 2023.

I want to create a page specific to the 'FactB' (max 2023).

I also want to calculate anything using my Date table to keep it at the center of any calculation involving dates.

 

If I create a segment with 'Date'[Date], I will have 2024 has the max date.

 

For instance I have several measures :

MaxYear = YEAR(MAXX(allselected('Date'[Date]),'Date'[Date]))
MaxYear-1 = [MaxYear]-1
MaxYear-2 = [MaxYear]-2
 
If I put MaxYear in a card, by default it display 2024. I wish in my case that it displays 2023.
Obviously I want MaxYear-1 & MaxYear-2 to follow.
 
I tried a trick with a filter like TableB[id] is not null without success.
 
I will clarify if necessary.

I looked in several other posts but somehow didn't find something related. Happy to know if you are more lucky.
1 ACCEPTED SOLUTION

see attached. 

 

NOTE1 :  This is a measure filter on a visual. If your data sources are in import mode you could add a calculated column to the calendar table instead and make it a page or report filter.

NOTE2 :  You are comparing filter context to scalar value.  I chose the MIN aggregation to include the entire filter context. You could use MAX instead to cut off exactly at the date.

View solution in original post

6 REPLIES 6
lbendlin
Super User
Super User

What's preventing you from using the filter pane "Filters on this page"  ?

bol
Frequent Visitor

Nothing is preventing me from using it except the way to use it or my skill.

Which measure should I put there? 'MaxYear' ?
Which criteria should I set on that measure? 'less than' what ?

I am looking for a dynamic solution. I don't want to set a constant otherwise I will have to change it (or the user) as soon as there will be data in 2024.

bol
Frequent Visitor

I am preparing an example.

In parallel I will add a flag in my date table to tag all dates where there is data in FactB. I will filter on that tag afterward.

bol
Frequent Visitor

Here is the example.

In page ViewAll, no filter. In page View B, I filtered manually with date less than 2024. I wish to to make that filter automatic to max FactB[Date].

MaxDateTableB.pbix 

 

see attached. 

 

NOTE1 :  This is a measure filter on a visual. If your data sources are in import mode you could add a calculated column to the calendar table instead and make it a page or report filter.

NOTE2 :  You are comparing filter context to scalar value.  I chose the MIN aggregation to include the entire filter context. You could use MAX instead to cut off exactly at the date.

bol
Frequent Visitor

Thank you for the measure. It helped to save some time instead of figuring it out by myself.
I added it to my calendar table, and after fixing my dates columns it worked nicely as a filter.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.