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

filter dates on multiple tables without relationship

Hello, 

 

I am having an issue with a model. I have five tables that need to be linked using an ID, which works fine. But in addition, I would like to have a general Date filter that filters all those five tables at once. 

 

Note that I can't create a second relationship using the Date columns, because I need my ID relationships to go both ways. The second relationship creates ambiguity. Here is the model: 

 

slau2702_0-1609753871420.png

 

An advice I got was to filter dates in every measure I create using DAX. for example: 

 

Distinct.count =
var MinDate = min(DateTable[Date])
var MaxDate= max(DateTable[Date])
var val = values(AsRun[Date])

RETURN
CALCULATE(
DISTINCTCOUNT(AsRun[TV Link]);
Filter(val; AsRun[Date] >= MinDate);
FILTER(val;AsRun[Date] <= MaxDate))
 
The problem is that all pages still show all the dates (in tables, slicers,...). Only the final results of the calculations are filtered. 

 

Does anyone know a way to get around this problem? 

 

Thanks a lot,  and happy new year.

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

According to my understanding, you want to use Date for Slicer to filter all other tables when there are relationships among the other tables but no between Date table and the others, right?

Please try to use the following formula and then apply it(set as "is 1") to all visuals:

Measure =
VAR _min =
    MIN ( 'Date'[Date] )
VAR _max =
    MAX ( 'Date'[Date] )
VAR _idTab1 =
    SUMMARIZE (
        FILTER (
            ALL ( 'Table1' ),
            MAX ( 'Table1'[Date] ) >= _min
                && MAX ( 'Table1'[Date] ) <= _max
        ),
        [ID]
    )
RETURN
    IF ( MAX ( 'Fact'[ID] ) IN _idTab1, 1, 0 )

 

The final output is shown below:

1.6.1.1.gif

Here is the pbix file.

 

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

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it.

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Thanks  @Anonymous, 

 

I had to adapt your formula because I want the tables to be each filtered by date, independently of IDs. 

 

So I used this formula as a filter in each visual and it does the job: 

 

Filter Date =
var MinDate = min(DateTable[Date])
var MaxDate= max(DateTable[Date])
 
RETURN
IF(OR(FIRSTDATE('table1'[Date]) > MaxDate; LASTDATE('table1'[Date]) < MinDate);0;1)

 

Thanks for your replies.

 

Regards.

 

 

 

Anonymous
Not applicable

Hi @Anonymous ,

 

According to my understanding, you want to use Date for Slicer to filter all other tables when there are relationships among the other tables but no between Date table and the others, right?

Please try to use the following formula and then apply it(set as "is 1") to all visuals:

Measure =
VAR _min =
    MIN ( 'Date'[Date] )
VAR _max =
    MAX ( 'Date'[Date] )
VAR _idTab1 =
    SUMMARIZE (
        FILTER (
            ALL ( 'Table1' ),
            MAX ( 'Table1'[Date] ) >= _min
                && MAX ( 'Table1'[Date] ) <= _max
        ),
        [ID]
    )
RETURN
    IF ( MAX ( 'Fact'[ID] ) IN _idTab1, 1, 0 )

 

The final output is shown below:

1.6.1.1.gif

Here is the pbix file.

 

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

Hello!
I just stumbled upon the same problem, but sadly cant open the pbix file you attached, I went through the process, used this code as per the last reply :

0DateFilter =
var MinDate = min('Calendar'[Date])
var MaxDate= max('Calendar'[Date])

RETURN
    IF ( OR(FIRSTDATE(WorkLog[Datecolumn])>MaxDate,LASTDATE(WorkLog[Datecolumn]) < MinDate),0,1),  measure shown no erro but i couldnt use it as a filter in my visuals since this  error popped up when used, any advice ?

TBhelpneeded_0-1717158811506.png

Thanks a lot !

amitchandak
Super User
Super User

@Anonymous , Ideally, you should be able to join with date table, all these 5. Make some bi-directional joins as single directional and that will work.

 

Or try measure like

 

Distinct.count =
var MinDate = minx(allselected(DateTable), DateTable[Date])
var MaxDate= maxx(allselected(DateTable),DateTable[Date])
var val = values(AsRun[Date])

RETURN
CALCULATE(
DISTINCTCOUNT(AsRun[TV Link]);
Filter(AsRun; AsRun[Date] >= MinDate && AsRun[Date] <= MaxDate))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.