Specific range by week number

Mikkelelgaard

New Member
Joined
May 3, 2021
Messages
2
Office Version
  1. 365
Platform
  1. MacOS
Hi all! I am currently working on some sales data where I have to calculate the standard deviation and average of each item. However, I only want to include the weeks where the product has been sold (so from the first week with sales to the last week with sales).
With MATCH and LOOKUP I have managed to find the week numbers, but what I struggle with is how I can use it as a range in AVERAGE and STDEV.S?

Hope someone has the answer :)

Help please.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBH
1Row Labels1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253First SaleLast saleFirst week with salesLast week with salesStDevAverage
2105017151301109103000090000221151201021112060104010022110421026806280122270923616050400000444400300503025293.377870555.6415094
3200000000000000000000000000000000002002000220030512652001104052304313503801301015211220200203553513.234985153.245283
43000000000000000000000000000000000010010002200298149501305355101130024029313756414522083851003853553994.085782391.641509
540000000000000000000000000000000000200200022002211275010058653024193106002503253007302007303553440.206204156.811321
65000000000000000000000000000000000020020000202016160510290208201332604040320200200203552370.932854116.830189
76000000000000000000000000000000000020020000216015650510450230800446030801177459200200203552395.171547145.396226
87000000000000000000000000000000000020020000171316250500290193540337030414131180002001803551335.104264115.45283
9816000102005000020001000200000000001010001000000000000001000111509.154535232.66037736
1091110001430010519201030020001010052121045020600018103502000590101760201600016001615130.228976216.5471698
1110013200362010201510000200010002100000010010101000005000010041030010001321025119.95693847.09433962
Sheet1
Cell Formulas
RangeFormula
BC2:BC11BC2=INDEX(B2:BB2,MATCH(TRUE,B2:BB2>0,0))
BD2:BD11BD2=LOOKUP(9.999999999999E+307,IF(B2:BB2>0,B2:BB2))
BE2:BE11BE2=MATCH(BC2,B2:BB2,0)
BF2:BF11BF2=LOOKUP(2,1/(B2:BB2=BD2),$B$1:$BB$1)
BG2:BG11BG2=STDEV.S(B2:BB2)
BH2:BH11BH2=AVERAGE(B2:BB2)
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How about
Excel Formula:
=STDEV.S(INDEX(B2:BB2,BE2):INDEX(B2:BB2,BF2))
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,225,474
Messages
6,185,192
Members
453,282
Latest member
roger_nz66

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