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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
markuslegeler
New Member

DAX command for continuous sum bassed on each row

Dear community,
I already tried several possibilities to sum up row by row based on the following table:

quantity in kg Pt/Ruunit (kg)typesortingIndexactual stockexpected values
66,902103kglocal stock453860if local stock = using the number of column quantity in kg Pt/Ru66,902103
50kgorder458361if order deduct column quantity in kg Pt/Ru from previous row of actual stock16,902103
25kgorder458632if order deduct column quantity in kg Pt/Ru from previous row of actual stock-8,097897
25kgorder458633if order deduct column quantity in kg Pt/Ru from previous row of actual stock-33,097897
32,5kgproduction order458874if production order add column quantity in kg Pt/Ru from previous row of actual stock-0,597897
32,5kgproduction order459015if production order add column quantity in kg Pt/Ru from previous row of actual stock31,902103

But no proposed formula delivered the expected values.

Is anybody able to help.

Thanks in advance.

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Actual = 
CALCULATE(
    CALCULATE(
        SUM( STK[Quantity in kg Pt/Ru] ),
        STK[Type] IN { "local stock", "production order" }
    )
        - CALCULATE( SUM( STK[Quantity in kg Pt/Ru] ), STK[Type] = "order" ),
    STK[Index] <= EARLIER( STK[Index] ),
    REMOVEFILTERS()
)

ThxAlot_0-1712342649961.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

3 REPLIES 3
ThxAlot
Super User
Super User

Actual = 
CALCULATE(
    CALCULATE(
        SUM( STK[Quantity in kg Pt/Ru] ),
        STK[Type] IN { "local stock", "production order" }
    )
        - CALCULATE( SUM( STK[Quantity in kg Pt/Ru] ), STK[Type] = "order" ),
    STK[Index] <= EARLIER( STK[Index] ),
    REMOVEFILTERS()
)

ThxAlot_0-1712342649961.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



markuslegeler
New Member

Sorry to ask a stupid question, did you put in the DAX directly in the visual or in the table as new column?
Do I need to replace Table with the name of my existing table?

lbendlin
Super User
Super User

Here is one example 

 

lbendlin_0-1712253962116.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.