Forum Discussion

Rai_BI's avatar
Rai_BI
Helper IV
2 years ago
Solved

Slow problems when calculating Pareto

Hello everybody, I need to calculate the Pareto of the products, but I am unable to do so, PowerBI desktop is exceeding the available memory. I've already tried doing the calculation in several diff...
  • xifeng_L's avatar
    xifeng_L
    2 years ago

    Hi Rai_BI ,

     

    Pls try the following measure, which has the best performance and takes ablout 90 seconds.

     

     

    Paretto% - optimized2 = 
    VAR vIndex =
        ROWNUMBER (
            ALL ( 'dProducts'[NAME_PRODUCT],'dProducts'[ID_PRODUCT] ),
            ORDERBY ( [Sales Amount], DESC )
        )
    VAR vSales = [Sales Amount]
    VAR vTempTable = 
        ADDCOLUMNS ( 
            ALL ( 'dProducts'[NAME_PRODUCT],'dProducts'[ID_PRODUCT] ), 
            "Sales", [Sales Amount] 
        )
    VAR vSalesTotal =
        SUMX ( vTempTable, [Sales] )
    RETURN
        SUMX (
            WINDOW ( 0, ABS, vIndex, ABS, vTempTable, ORDERBY ( [Sales], DESC ) ),
            [Sales]
        ) / vSalesTotal

     

     

     

    The other optimised measure takes about ten minutes.

     

     

     

    From your original measure that would exceed the memory, first optimising to about 10 minutes, then continuing to optimise to 90 seconds, it feels like the limit of the optimisation has been reached, and if 90 seconds doesn't satisfy the demand, there's nothing I can do about it.

     

     

    Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

     

    Thank you~