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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
sarahomar955
Regular Visitor

DAX takes 60 seconds to load with many what if numeric parameters

 
Hi, 
I have the following dax that uses measures where i addded the user numeric parameters with our values and i want to put them in my matrix but the performance is super slow, here is the dax of the final measure.
 
 
Total_Customers_2 =
var AllActuals = [All Actuals]
var notselected_customers = [notselected_customers]
return IF(
    SELECTEDVALUE('SBI Actuals Agg (x100)'[Line of Items]) = "[NE]", FORMAT(CALCULATE([Nes_time_new] + notselected_customers+AllActuals), "#,##0"),
    IF(
        SELECTEDVALUE('SBI Actuals Agg (x100)'[Line of Items]) = "[L66]", FORMAT(CALCULATE([L6_time_new] + notselected_customers+AllActuals), "#,##0"),
        IF(
            SELECTEDVALUE('SBI Actuals Agg (x100)'[Line of Items]) = "[L66b]", FORMAT(CALCULATE([L6b_time_new] + notselected_customers+AllActuals), "#,##0"),
            IF(
                SELECTEDVALUE('SBI Actuals Agg (x100)'[Line of Items]) = "[C11]", FORMAT(CALCULATE([c1_time_new_] + notselected_customers+AllActuals), "#,##0"),
                IF(
                    SELECTEDVALUE('SBI Actuals Agg (x100)'[Line of Items]) = "[L110]", FORMAT(CALCULATE([L10_time_new] + notselected_customers+AllActuals), "#,##0"),    
                    IF(
                        SELECTEDVALUE('SBI Actuals Agg (x100)'[Line of Items]) IN { "[GE]", "[L66a]",  "[L1]", "[L2]", "[L3]", "[Net Weight]" }, FORMAT([Fixed_Date_Total_Customers]+AllActuals, "#,##0"),
                        IF(
                            SELECTEDVALUE('Sorting Index'[Line]) = "C1", FORMAT([c1PerNes_total], "#0.00%"),
                            IF(
                                SELECTEDVALUE('SBI Actuals Agg (x100)'[Line of Items]) = "[L14]", FORMAT(CALCULATE([L14_time_new] + notselected_customers+AllActuals), "#,##0"),    
                                        BLANK()
                        )
                    )
                )
            )
        )
    )))
   
   
   
2 REPLIES 2
Anonymous
Not applicable

Hi @sarahomar955 ,


Please try:

Total_Customers_2 =
VAR Base = [notselected_customers] + [AllActuals]
VAR SelectedLine =
    SELECTEDVALUE ( 'SBI Actuals Agg (x100)'[Line of Items] )
VAR Result =
    SWITCH (
        SelectedLine,
        "[NE]", CALCULATE ( [Nes_time_new] + Base ),
        "[L66]", CALCULATE ( [L6_time_new] + Base ),
        "[L66b]", CALCULATE ( [L6b_time_new] + Base ),
        "[C11]", CALCULATE ( [c1_time_new] + Base ),
        "[L110]", CALCULATE ( [L10_time_new] + Base ),
        { [GE], "[L66a]", "[L1]", "[L2]", "[L3]", "[Net Weight]" }, [Fixed_Date_Total_Customers] + [AllActuals],
        "[L14]", CALCULATE ( [L14_time_new] + Base ),
        "C1", [c1PerNes_total]
    )
VAR NumericValue =
    IF ( ISNUMBER ( Result ), Result, [Fixed_Date_Total_Customers] + [AllActuals] )
RETURN
    FORMAT ( NumericValue, "#,##0" )

 Optimizing IF conditions by using variables - SQLBI

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

lbendlin
Super User
Super User

Use DAX Studio to examine the query plan for that query and then see if you can refactor it.

 

Note that "SELECTEDVALUE"  needs to be complemented with TREATAS filters.

Helpful resources

Announcements
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.