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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
nbufff
Helper I
Helper I

Error showed not enough memory by using Earlier

Hello all,

I encounter the error by showing not enough memory when using earlier funciton.

My purpose is to get accumulated qty based on same date and same sku. The example below:

Date_CreatedMaterialQuantityIndexAccumulated_Qty
25-OctA1001100
25-OctA2002300
25-OctA3003600
25-OctB4004400
25-OctB5005900
25-OctB60061500

 

The DAX I used:

Accumulated_Qty =

VAR SumQuantity =
    CALCULATE(
        SUM(Basic_1[Quantity]),
        FILTER(
            Basic_1,
            Basic_1[Index]<= EARLIER(Basic_1[Index]) &&
            Basic_1[Material] = EARLIER(Basic_1[Material]) &&
            Basic_1[Date created] = EARLIER(Basic_1[Date created])
        )
    )
RETURN
    IF(ISBLANK(SumQuantity), 0, SumQuantity)

 

I also tried to use var but still failed:

Qty_Accum =
VAR CurrentIndex = Basic_1[Index]
VAR CurrentMaterial = Basic_1[Material]
VAR CurrentDate = Basic_1[Date created]

RETURN
SUMX(
FILTER(
Basic_1,
Basic_1[Index] <= CurrentIndex &&
Basic_1[Material] = CurrentMaterial &&
Basic_1[Date created] = CurrentDate
),
Basic_1[Quantity]
)

 

Is there any other way to improve that? Thanks for help!

1 ACCEPTED SOLUTION
xifeng_L
Super User
Super User

Hi @nbufff 

 

Can try the window function, It may have better performance.

 

xifeng_L_1-1729850536961.png

 

 

Accumulated_Qty = 
SUMX(
    WINDOW(1,ABS,0,REL,ORDERBY('Basic_1'[Index],ASC,'Basic_1'[Quantity]),PARTITIONBY(Basic_1[Date_Created],'Basic_1'[Material])),
    'Basic_1'[Quantity]
)

 

 

 

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

 

Thank you~

View solution in original post

2 REPLIES 2
nbufff
Helper I
Helper I

Great solution. Thanks to let me know the Window fuction.

xifeng_L
Super User
Super User

Hi @nbufff 

 

Can try the window function, It may have better performance.

 

xifeng_L_1-1729850536961.png

 

 

Accumulated_Qty = 
SUMX(
    WINDOW(1,ABS,0,REL,ORDERBY('Basic_1'[Index],ASC,'Basic_1'[Quantity]),PARTITIONBY(Basic_1[Date_Created],'Basic_1'[Material])),
    'Basic_1'[Quantity]
)

 

 

 

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

 

Thank you~

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.