cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gggar
Helper I
Helper I

Cumulative of (Value^2)

Hello,

I have a question to calculate running sum of a formula.

 

I have a table

gggar_0-1621427342534.png

 

I want to calculate the running sum of (Value^2).

I expect to have for each row:

(7^2) = 49

(7^2) + (1^2) = 50

(7^2) + (1^2) + (2^2) = 54

 

I tried to do it in DAX

Measure 5 = 
CALCULATE (
    SUM (Master[Value]) * SUM (Master[Value]),
    FILTER (
        ALL ( Master ),
        Master[Date] <= MAX ( Master[Date] )
    )
)

 

But the result is

gggar_1-1621427469270.png

 

 

Anyone can help me for the correct DAX to get 49, 50, and 54 as the running sum?

Any help will be greatly appreciated! Thank you.

1 ACCEPTED SOLUTION
Fowmy
Super User IV
Super User IV

@gggar 

Use the formula this way:

Value Measure = 
var _date =  MAX(Master[Date]) return
CALCULATE(
    SUMX(VALUES(Master), Master[Value] * Master[Value]),
    Master[Date] <=_date 
)

 

Fowmy_0-1621428468572.png

 

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Blog - Data Visualization

Website   YouTube    LinkedIn   PBI User Group

View solution in original post

2 REPLIES 2
gggar
Helper I
Helper I

@Fowmy , thanks a lot!

Fowmy
Super User IV
Super User IV

@gggar 

Use the formula this way:

Value Measure = 
var _date =  MAX(Master[Date]) return
CALCULATE(
    SUMX(VALUES(Master), Master[Value] * Master[Value]),
    Master[Date] <=_date 
)

 

Fowmy_0-1621428468572.png

 

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Blog - Data Visualization

Website   YouTube    LinkedIn   PBI User Group

View solution in original post

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors