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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
v-cgao-msft
Community Support
Community Support

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
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors