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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
zazaalaza
Frequent Visitor

DAX too Slow with Filtering

Hi,

I have the following measure:

Measure = 
    CALCULATE ( 
        COUNT ( 'Table'[Value] ), 
        FILTER ( 
            ALL ( 'Table' ), 
            'Table'[ValidFromDate] < MAX ( 'Date'[Date] ) && 
            'Table'[ValidToDate] > MAX ( 'Date'[Date] ) 
        ) 
    )


The two tables (Table, Date) are not connected.

I use this to see "Active" contracts on a specific date. However when I place it in a visual to see it on a daily basis (last 12 months for example), it is way too slow (I have 12 million rows). 

Is there a way to optimize this?
Much appreciated!

4 REPLIES 4
zazaalaza
Frequent Visitor

Perhaps there is a way to make it faster without using Calculate? @Greg_Deckler Any ideas? 

Yeah, I have seen this pattern be slow occasionally.

Without CALCULATE can be written fairly similarly.

Measure =
VAR _MaxDate = MAX ( 'Date'[Date] )
RETURN
    COUNTROWS (
        FILTER (
            ALL ( 'Table' ),
            'Table'[ValidFromDate] < _MaxDate &&
            'Table'[ValidToDate]   > _MaxDate
        )
    )
AlexisOlson
Super User
Super User

It might help to make the max date a variable.

Measure =
VAR _MaxDate = MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        COUNT ( 'Table'[Value] ),
        ALL ( 'Table' ),
        'Table'[ValidFromDate] < _MaxDate,
        'Table'[ValidToDate] > _MaxDate
    )

Thanks but that doesn't help.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.