I am looking for a formula to be able to return the total amount in each week number.

JennyP

New Member
Joined
Sep 5, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
EG: we produce something in week 2015 then we sell it in 2022. This product is on the ground for 7 weeks. The information I have is:

Production week Delivery week QTY
2015 2022 10
2015 2021 5
2016 2028 12
2018 2030 13
2019 2025 8

I need to be able to calculate the total qty that we have for each week. EG 2015 = 15, 2016 = 27.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi JennyP,

I can't see why 2016 would be 27 and not 12 but if that's a typo then does this work?

Book2
ABCDEF
1Production weekDelivery weekQTYProduction weekTotal
22015202210201515
3201520215201612
42016202812201813
5201820301320198
6201920258 0
Sheet1
Cell Formulas
RangeFormula
E2E2=MIN($A$2:$A$999)
F2:F6F2=SUMIFS($C$2:$C$999,$A$2:$A$999,E2)
E3:E6E3=IFERROR(INDEX($A$2:$A$999,AGGREGATE(15,6,ROW($A$2:$A$999)-ROW($A$1)/($A$2:$A$999>E2),1)),"")
 
Upvote 0
with Pivot Table

Production weekSum of QTY
201515
201612
201813
20198


or Running Total with Power Query (Get&Transform)

Production weekDelivery weekQTYRunning Total
201520221010
20152021515
201620281227
201820301340
20192025848

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Index = Table.AddIndexColumn(Source, "Index", 1, 1),
    Sum = Table.AddColumn(Index, "Running Total", each List.Sum(List.Range(Index[QTY],0,[Index]))),
    RC = Table.RemoveColumns(Sum,{"Index"})
in
    RC
 
Last edited:
Upvote 0
or like this

Production weekQTYRunning Total
20151515
20161227
20181340
2019848

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Production week"}, {{"QTY", each List.Sum([QTY]), type number}}),
    Index = Table.AddIndexColumn(Group, "Index", 1, 1),
    Sum = Table.AddColumn(Index, "Running Total", each List.Sum(List.Range(Index[QTY],0,[Index]))),
    RC = Table.RemoveColumns(Sum,{"Index"})
in
    RC

I overlooked this in the first post
2015 = 15, 2016 = 27.
 
Last edited:
Upvote 0
Hi JennyP,

I can't see why 2016 would be 27 and not 12 but if that's a typo then does this work?

Book2
ABCDEF
1Production weekDelivery weekQTYProduction weekTotal
22015202210201515
3201520215201612
42016202812201813
52018203013[
Hi JennyP, I can't see why 2016 would be 27 and not 12 but if that's a typo then does this work?
Book2
ABCDEF
1Production weekDelivery weekQTYProduction weekTotal
22015202210201515
3201520215201612
42016202812201813
5201820301320198
6201920258 0
Sheet1
Cell Formulas
RangeFormula
E2E2=MIN($A$2:$A$999)
F2:F6F2=SUMIFS($C$2:$C$999,$A$2:$A$999,E2)
E3:E6E3=IFERROR(INDEX($A$2:$A$999,AGGREGATE(15,6,ROW($A$2:$A$999)-ROW($A$1)/($A$2:$A$999>E2),1)),"")
Hi JennyP, I can't see why 2016 would be 27 and not 12 but if that's a typo then does this work?
Book2
ABCDEF
1Production weekDelivery weekQTYProduction weekTotal
22015202210201515
3201520215201612
42016202812201813
5201820301320198
6201920258 0
Sheet1
Cell Formulas
RangeFormula
E2E2=MIN($A$2:$A$999)
F2:F6F2=SUMIFS($C$2:$C$999,$A$2:$A$999,E2)
E3:E6E3=IFERROR(INDEX($A$2:$A$999,AGGREGATE(15,6,ROW($A$2:$A$999)-ROW($A$1)/($A$2:$A$999>E2),1)),"")
Hi Toadstool, I probably have not explained the situation correctly.. so here goes.... we produce the product (qty of 5) in week 2020 then we sell the product in week 2025. This means that we have 5 on the ground in week 2020, 5 in wk 2021, 5 in wk 2022, 5 in week 2023, 5 in week 2024 then 0 in week 2025. we then produce 2 in week 2022 and sell it in 2024. the total on the ground each week would be 2020 x 5, 2021 x 5, 2022 x 7, 2023 x 7, 2024 x 5, 2025 x 0 I hope this explains it a little better. /XD][XD]
20198
6201920258 0
Sheet1
Cell Formulas
RangeFormula
E2E2=MIN($A$2:$A$999)
F2:F6F2=SUMIFS($C$2:$C$999,$A$2:$A$999,E2)
E3:E6E3=IFERROR(INDEX($A$2:$A$999,AGGREGATE(15,6,ROW($A$2:$A$999)-ROW($A$1)/($A$2:$A$999>E2),1)),"")
 
Upvote 0
Hi Toadstool, I probably have not explained the situation correctly.. so here goes.... we produce the product (qty of 5) in week 2020 then we sell the product in week 2025. This means that we have 5 on the ground in week 2020, 5 in wk 2021, 5 in wk 2022, 5 in week 2023, 5 in week 2024 then 0 in week 2025. we then produce 2 in week 2022 and sell it in 2024. the total on the ground each week would be 2020 x 5, 2021 x 5, 2022 x 7, 2023 x 7, 2024 x 5, 2025 x 0 I hope this explains it a little better.
 
Upvote 0
Hi JennyP,

So your example doesn't have an example where a Delivery Date has yet passed. Maybe you could give a worked example in the format of a spreadsheet, or maybe this is it?

Book2
ABCDEF
1Production weekDelivery weekQTYProduction weekTotal
22015202210201515
3201520215201627
42016202412201840
52018202613201948
6201920258202147
7202120234202243
8202220256202339
9202320260202427
10202420260202513
1120252026020260
1220262026020270
13202720260 0
Sheet1
Cell Formulas
RangeFormula
E2E2=MIN($A$2:$A$999)
F2:F13F2=SUMIFS($C$2:$C$999,$A$2:$A$999,"<="&E2,$B$2:$B$999,">"&E2)
E3:E13E3=IFERROR(INDEX($A$2:$A$999,AGGREGATE(15,6,ROW($A$2:$A$999)-ROW($A$1)/($A$2:$A$999>E2),1)),"")
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top