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
sarahomar955
Regular Visitor

Dax query performance issue

Hello, i have 2 measures, the second one calls the first one but i need to optimize them since they are taking long time to compute with large data:

 

Measure 1:

L10\ = DIVIDE(CALCULATE(SUM('SBI Actuals Agg (x100)'[Actuals]),FILTER(ALLEXCEPT('SBI Actuals Agg (x100)',
'SBI Actuals Agg (x100)'[pc],'SBI Actuals Agg (x100)'[Country],
'SBI Actuals Agg (x100)'[ch],'SBI Actuals Agg (x100)'[mc],
'SBI Actuals Agg (x100)'[brand], 'SBI Actuals Agg (x100)'[ch3]),'SBI Actuals Agg (x100)'[Line of Items]="[L10]"))
,(CALCULATE(SUM('SBI Actuals Agg (x100)'[Actuals]),FILTER(ALLEXCEPT('SBI Actuals Agg (x100)','SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],'SBI Actuals Agg (x100)'[ch],'SBI Actuals Agg (x100)'[mc],  'SBI Actuals Agg (x100)'[brand],
 'SBI Actuals Agg (x100)'[ch3]),'SBI Actuals Agg (x100)'[Line of Items]="[GES]"))-CALCULATE(SUM('SBI Actuals Agg (x100)'[Actuals]),
 FILTER(ALLEXCEPT('SBI Actuals Agg (x100)','SBI Actuals Agg (x100)'[pc],'SBI Actuals Agg (x100)'[Country],'SBI Actuals Agg (x100)'[ch],
 'SBI Actuals Agg (x100)'[mc],  'SBI Actuals Agg (x100)'[brand], 'SBI Actuals Agg (x100)'[ch3]),'SBI Actuals Agg (x100)'[Line of Items]="[L6a]"))),0)
 
Measure 2:
L10_time_new = [L10\]
*

(CALCULATE([selected_customers_total],FILTER(ALLEXCEPT('SBI Actuals Agg (x100)','SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],'SBI Actuals Agg (x100)'[ch],'SBI Actuals Agg (x100)'[mc], 'SBI Actuals Agg (x100)'[brand], 'SBI Actuals Agg (x100)'[ch3]),
'SBI Actuals Agg (x100)'[Line of Items]="[GES]"))
-

CALCULATE([selected_customers_total],FILTER(ALLEXCEPT('SBI Actuals Agg (x100)','SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],'SBI Actuals Agg (x100)'[ch],'SBI Actuals Agg (x100)'[mc],  'SBI Actuals Agg (x100)'[brand], 'SBI Actuals Agg (x100)'[ch3]),
'SBI Actuals Agg (x100)'[Line of Items]="[L6a]")))

 +

 ([L10\]
 
 *
 
 (CALCULATE([selected_customers_total],FILTER(ALLEXCEPT('SBI Actuals Agg (x100)'
,'SBI Actuals Agg (x100)'[pc],'SBI Actuals Agg (x100)'[Country],'SBI Actuals Agg (x100)'[ch],
'SBI Actuals Agg (x100)'[mc],  'SBI Actuals Agg (x100)'[brand], 'SBI Actuals Agg (x100)'[ch3]),'SBI Actuals Agg (x100)'[Line of Items]="[GES]"))
-
CALCULATE([selected_customers_total],
FILTER(ALLEXCEPT('SBI Actuals Agg (x100)','SBI Actuals Agg (x100)'[pc],'SBI Actuals Agg (x100)'[Country],
'SBI Actuals Agg (x100)'[ch],'SBI Actuals Agg (x100)'[mc],  'SBI Actuals Agg (x100)'[brand], 'SBI Actuals Agg (x100)'[ch3]),'SBI Actuals Agg (x100)'[Line of Items]="[L6a]")))

*

(L10[L10 Value]/100))
 
 
 
Can you help me optimize these dax queries for better performance?
1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@sarahomar955 , Try using variables

For measure 1

dax
L10 =
VAR Actuals_L10 =
CALCULATE(
SUM('SBI Actuals Agg (x100)'[Actuals]),
FILTER(
ALLEXCEPT(
'SBI Actuals Agg (x100)',
'SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],
'SBI Actuals Agg (x100)'[ch],
'SBI Actuals Agg (x100)'[mc],
'SBI Actuals Agg (x100)'[brand],
'SBI Actuals Agg (x100)'[ch3]
),
'SBI Actuals Agg (x100)'[Line of Items] = "[L10]"
)
)

VAR Actuals_GES =
CALCULATE(
SUM('SBI Actuals Agg (x100)'[Actuals]),
FILTER(
ALLEXCEPT(
'SBI Actuals Agg (x100)',
'SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],
'SBI Actuals Agg (x100)'[ch],
'SBI Actuals Agg (x100)'[mc],
'SBI Actuals Agg (x100)'[brand],
'SBI Actuals Agg (x100)'[ch3]
),
'SBI Actuals Agg (x100)'[Line of Items] = "[GES]"
)
)

VAR Actuals_L6a =
CALCULATE(
SUM('SBI Actuals Agg (x100)'[Actuals]),
FILTER(
ALLEXCEPT(
'SBI Actuals Agg (x100)',
'SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],
'SBI Actuals Agg (x100)'[ch],
'SBI Actuals Agg (x100)'[mc],
'SBI Actuals Agg (x100)'[brand],
'SBI Actuals Agg (x100)'[ch3]
),
'SBI Actuals Agg (x100)'[Line of Items] = "[L6a]"
)
)

RETURN
DIVIDE(Actuals_L10, Actuals_GES - Actuals_L6a, 0)

 

and for measure 2

dax
L10_time_new =
VAR L10_Value = [L10]

VAR Selected_Customers_GES =
    CALCULATE(
        [selected_customers_total],
        FILTER(
            ALLEXCEPT(
                'SBI Actuals Agg (x100)',
                'SBI Actuals Agg (x100)'[pc],
                'SBI Actuals Agg (x100)'[Country],
                'SBI Actuals Agg (x100)'[ch],
                'SBI Actuals Agg (x100)'[mc],
                'SBI Actuals Agg (x100)'[brand],
                'SBI Actuals Agg (x100)'[ch3]
            ),
            'SBI Actuals Agg (x100)'[Line of Items] = "[GES]"
        )
    )

VAR Selected_Customers_L6a =
    CALCULATE(
        [selected_customers_total],
        FILTER(
            ALLEXCEPT(
                'SBI Actuals Agg (x100)',
                'SBI Actuals Agg (x100)'[pc],
                'SBI Actuals Agg (x100)'[Country],
                'SBI Actuals Agg (x100)'[ch],
                'SBI Actuals Agg (x100)'[mc],
                'SBI Actuals Agg (x100)'[brand],
                'SBI Actuals Agg (x100)'[ch3]
            ),
            'SBI Actuals Agg (x100)'[Line of Items] = "[L6a]"
        )
    )

VAR L10_Part = L10_Value * (Selected_Customers_GES - Selected_Customers_L6a)

RETURN
    L10_Part + (L10_Value * (Selected_Customers_GES - Selected_Customers_L6a) * (L10[L10 Value] / 100))



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

1 REPLY 1
bhanu_gautam
Super User
Super User

@sarahomar955 , Try using variables

For measure 1

dax
L10 =
VAR Actuals_L10 =
CALCULATE(
SUM('SBI Actuals Agg (x100)'[Actuals]),
FILTER(
ALLEXCEPT(
'SBI Actuals Agg (x100)',
'SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],
'SBI Actuals Agg (x100)'[ch],
'SBI Actuals Agg (x100)'[mc],
'SBI Actuals Agg (x100)'[brand],
'SBI Actuals Agg (x100)'[ch3]
),
'SBI Actuals Agg (x100)'[Line of Items] = "[L10]"
)
)

VAR Actuals_GES =
CALCULATE(
SUM('SBI Actuals Agg (x100)'[Actuals]),
FILTER(
ALLEXCEPT(
'SBI Actuals Agg (x100)',
'SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],
'SBI Actuals Agg (x100)'[ch],
'SBI Actuals Agg (x100)'[mc],
'SBI Actuals Agg (x100)'[brand],
'SBI Actuals Agg (x100)'[ch3]
),
'SBI Actuals Agg (x100)'[Line of Items] = "[GES]"
)
)

VAR Actuals_L6a =
CALCULATE(
SUM('SBI Actuals Agg (x100)'[Actuals]),
FILTER(
ALLEXCEPT(
'SBI Actuals Agg (x100)',
'SBI Actuals Agg (x100)'[pc],
'SBI Actuals Agg (x100)'[Country],
'SBI Actuals Agg (x100)'[ch],
'SBI Actuals Agg (x100)'[mc],
'SBI Actuals Agg (x100)'[brand],
'SBI Actuals Agg (x100)'[ch3]
),
'SBI Actuals Agg (x100)'[Line of Items] = "[L6a]"
)
)

RETURN
DIVIDE(Actuals_L10, Actuals_GES - Actuals_L6a, 0)

 

and for measure 2

dax
L10_time_new =
VAR L10_Value = [L10]

VAR Selected_Customers_GES =
    CALCULATE(
        [selected_customers_total],
        FILTER(
            ALLEXCEPT(
                'SBI Actuals Agg (x100)',
                'SBI Actuals Agg (x100)'[pc],
                'SBI Actuals Agg (x100)'[Country],
                'SBI Actuals Agg (x100)'[ch],
                'SBI Actuals Agg (x100)'[mc],
                'SBI Actuals Agg (x100)'[brand],
                'SBI Actuals Agg (x100)'[ch3]
            ),
            'SBI Actuals Agg (x100)'[Line of Items] = "[GES]"
        )
    )

VAR Selected_Customers_L6a =
    CALCULATE(
        [selected_customers_total],
        FILTER(
            ALLEXCEPT(
                'SBI Actuals Agg (x100)',
                'SBI Actuals Agg (x100)'[pc],
                'SBI Actuals Agg (x100)'[Country],
                'SBI Actuals Agg (x100)'[ch],
                'SBI Actuals Agg (x100)'[mc],
                'SBI Actuals Agg (x100)'[brand],
                'SBI Actuals Agg (x100)'[ch3]
            ),
            'SBI Actuals Agg (x100)'[Line of Items] = "[L6a]"
        )
    )

VAR L10_Part = L10_Value * (Selected_Customers_GES - Selected_Customers_L6a)

RETURN
    L10_Part + (L10_Value * (Selected_Customers_GES - Selected_Customers_L6a) * (L10[L10 Value] / 100))



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






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.