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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AlejandroPCar
Helper IV
Helper IV

A Performance Problem

Hi

 

I have a slow problem here. I have the follow measure: 

classifier = 
    VAR initial = MIN(conditions_table[initial_age])
    VAR final = MIN(conditions_table[final_age])
    VAR current = MIN(people_table[current_age)
RETURN
    IF(
        SUM(people_table[people]) = BLANK(),
        BLANK(),
        IF(
            AND(
                current >= inicial,
                current <= final
                ), 
            1, 
            0
        )
    )

Then the previous measure is in

programs = 
    VAR sum = SUMX(
        people_table,
        SUMX(
        conditions_table,
        classifier
        )
    )
RETURN
    sum

 My problem is the performance is absolutly slow. I tried before with CROSSJOIN instead the double SUMX but was worst. The idea is simple: There are over half million people in the people table. Each of them has the chance of be in the age range of every program in the conditions_table. So a person could belong to several programs at time. Currently there are over 300 conditions in the conditions table. My model is now compound by this two tables and other ones only for the purpose to serve as filters. 

 

So the target is for example, person A is in the program_group 1 and he can be in 13 programs but his age only allows him to be in 9. person B is the same group so can be in the same 13 programs but she is restricted to be in only 7. Both persons are from country A, so the total programs in country A will be 9 + 13 = 22. 

 

I use the classifier measure beacuse the result 0 or 1 is perfect to summarize and get totals. My two main tables are related by a both side many to many relationship (program_group column in both tables, this column has the program_group ID, and each ID have multiple programs that have its own age conditions). 

 

Hope someone can help me to improve my model performance. 

 

Thanks a lot. 

2 ACCEPTED SOLUTIONS
v-yuezhe-msft
Employee
Employee

@AlejandroPCar,

Nested SUMX executes slow because SUMX is an iterator and hence it will step through every row in the table 1 row at a time, when SUMX are nested, there is a multiplicative effect.

In your scenario, please use SUMMARIZE with ADDCOLUMNS and FILTER as described in this similar blog: https://powerpivotpro.com/2015/08/nested-sumx-or-dax-query/.

Regards,
Lydia

Community Support Team _ Lydia Zhang
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

Hi @v-yuezhe-msft

 

Thanks for your response and after several, several, several attempts finally I achieve a greatly boost of 50% faster measures. Thanks for your advice. 

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@AlejandroPCar,

Nested SUMX executes slow because SUMX is an iterator and hence it will step through every row in the table 1 row at a time, when SUMX are nested, there is a multiplicative effect.

In your scenario, please use SUMMARIZE with ADDCOLUMNS and FILTER as described in this similar blog: https://powerpivotpro.com/2015/08/nested-sumx-or-dax-query/.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yuezhe-msft

 

Thanks for your response and after several, several, several attempts finally I achieve a greatly boost of 50% faster measures. Thanks for your advice. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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