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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sathishsam
Helper II
Helper II

How do i optimize this DAX to blazing fast?

I have a very simple DAX funtion as below which takes 576 MS to compute. How do i make it even better

CALCULATE (
                SUM (Table1[SumCol] ),
                Table1[Date] = MAX ( Table1[Date] )
                    && Table1[ColA] = 1
                    && Table1[ColB] = 2
                    && Table1[ColC]="A"
                    && Table1[ID1] = SELECTEDVALUE(Table2[ID1])
                    && Table1[ID2] = SELECTEDVALUE(Table2[ID2])
            ),

Table1 has around 2 Million rows and 30 Columns
5 REPLIES 5
danextian
Super User
Super User

I don't have a sample model to test this one but try this:

=
CALCULATE (
    SUM ( Table1[SumCol] ),
    Table1[Date] = MAX ( Table1[Date] ),
    Table1[ColA] = 1,
    Table1[ColB] = 2,
    Table1[ColC] = "A",
    Table1[ID1] = SELECTEDVALUE ( Table2[ID1] ),
    Table1[ID2] = SELECTEDVALUE ( Table2[ID2] )
)

This articles goes  into the detail of optimizing multiple filters within CALCULATE.

https://www.sqlbi.com/articles/specifying-multiple-filter-conditions-in-calculate/ 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Its the same formula that i have currently. What is the change in your suggetion?

Each filterargument has its own column. Yours used &&.  The formula I suggested doesnt.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

Hi @sathishsam,

You can try to use the following measure formula if it helps with your scenario:

formula =
VAR preFiltered =
    CALCULATETABLE (
        Table1,
        FILTER (
            ALLSELECTED ( Table1 ),
            Table1[Date] = MAX ( Table1[Date] )
                && Table1[ColA] = 1
                && Table1[ColB] = 2
                && Table1[ColC] = "A"
        )
    )
VAR idList =
    INTERSECT ( VALUES ( Table2[ID1] ), VALUES ( Table2[ID2] ) )
RETURN
    SUMX ( FILTER ( preFiltered, [ID1] IN idList ), [SumCol] )

In addition, you can also take a look at following document about optimize the performance:

Improve Power BI Performance by Optimizing your DAX | by MAQ Software | MAQ Software | Medium

Regards,
Xiaoxin Sheng

Thank you for the time. 

I tried your suggetions and it didn't help much, it increased the timings. See below

sathishsam_0-1692591712943.png

 




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors