# Automatically calculate YTD from data in pivot table

#### monaldo12

##### New Member
Hi,

I have a pivot table with weeknumbers and sales over 2 years. However the currect year is updated every 4 weeks so the data is expending for year 2020, 2019 is already filled in till week 52. I would like to calculate the YTD sum of the current year 2020, but also of the past year 2019. So both I need a YTD sum till W02 for example. Is there a formula for this?
Additional question, can I also make a sum of the last two weeks depending on the latest week available in 2020? So I need a automatic sum of 2019 which is 200 and for 2020 of 240. By adding more data to year 2020 it needs to switch in the future to a sum of W5+W6, later to W10+W11 etc etc.

 week/year 2019 2020 W01 100 120 W02 100 120 W03 100

### Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Replies
0
Views
53
Replies
0
Views
85
Replies
1
Views
107
Replies
2
Views
254
Replies
3
Views
265

1,126,961
Messages
5,621,851
Members
415,862
Latest member
DemianGS

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back