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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

How to add previous row value with current one and then keep getting the summation

HI below is the table as input in power bi and below that is the output i would require in power bi. Please let me know how is it possible in calculated column or Measure. its basically addition of previous row with current row please see the example below:

 

Input:

Date                       Value
22march 2017             3

23march 2017             3

24march 2017             2

25march 2017             11

01 January 2018           5

 

Output:

Date                       Value      Final Value
22march 2017             3               3

23march 2017             3               6

24march 2017             2               8

25march 2017             11            19

01 January 2018           5             24

 

 

I would require the Final value to be calculated. Please let me know the steps or formulae required.

thanks,
Ankku

 

 

 

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

You can create a calculated column: 

 

Column = CALCULATE(SUM('Table3'[Value]),FILTER('Table3','Table3'[Date]<=EARLIER('Table3'[Date])))

 

q1.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
rosu
Regular Visitor

@Ashish_Mathur 

 

Thank you so much for your help. It does what I was looking for.

You are welcome.  If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
rosu
Regular Visitor

How do we calculate the prior row value and current row value? For example the Final Value being 3, 6, 5, 13

 

Date                       Value      Final Value
22march 2017             3               3

23march 2017             3               6

24march 2017             2               5

25march 2017             11            13

01 January 2018           5             16

Hi,

Try this calculated column formula

=[Value]+lookupvalue(data[value],data[date],calculate(max(data[date]),filter(data,data[date]<earlier(data[date]))))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

You can create a calculated column: 

 

Column = CALCULATE(SUM('Table3'[Value]),FILTER('Table3','Table3'[Date]<=EARLIER('Table3'[Date])))

 

q1.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello!! This is pretty much what I need but based on columns like in the picture below. Can I add a measure to add columns 2 into column 1, column 3 into colunm 2....

mluanacruz_0-1661298499586.png

 

 

Thank again for the help.

 

Michelle

Anonymous
Not applicable

@v-qiuyu-msft 

 

Hi,

 

Is it possible to do this for each week? I mean summing the values per week.

 

Thanks.

@v-qiuyu-msft thanks for the solution, it was exactly what I was looking for. I just have another question. Is it possible to perform the same calculation using a measure? If not, not a problem.

Hi @handrade,

 

Of course. You can create a measure below: 

 

Measure=CALCULATE(SUM('Table3'[Value]),FILTER(all('Table3'),'Table3'[Date]<=Max('Table3'[Date])))

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-qiuyu-msft ,

 

your formulas really helped me a lot. Now I have the question if the same calculation can be made in Power Query (Custom column)?

Link to image . Cuz I want to use my calculated columns in Data pane (Link to image ) as an import into new Power Queries.

 

Thanks a lot in advance.

Best regards

Saso

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.