SOLVED

Find last value in a row (that will change) and calculate weighted average

%3CLINGO-SUB%20id%3D%22lingo-sub-2777126%22%20slang%3D%22en-US%22%3EFind%20last%20value%20in%20a%20row%20(that%20will%20change)%20and%20calculate%20weighted%20average%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2777126%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20an%20extremely%20large%20data%20set%20so%20I%20think%20that%20using%20the%20offset%20function%20will%20be%20too%20time-consuming.%26nbsp%3B%20The%20columns%20are%20dates%20and%20will%20have%20new%20values%20added%20each%20month.%3C%2FP%3E%3CP%3EThe%20rows%20will%20change%20position%20as%20they%20are%20being%20ranked%20each%20month.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUltimately%20I%20am%20trying%20to%20put%20together%20a%20formula%20that%20will%20calculate%20a%20weighting%20value%20for%20each%20row.%26nbsp%3B%20This%20will%20be%20represented%20by%20a%20weighting%20value%20(W1)%20applied%20to%20the%20%25%20change%20in%20average%20values%20for%20the%20last%2012%20months%20(P1)%20as%20compared%20to%20the%2012%20months%20before%20that%20(P2)%20combined%20with%20a%20weighting%20value%20(W2)%20applied%20to%20the%26nbsp%3B%25%20change%20in%20average%20values%20for%20the%20period%20P2%20as%20compared%20to%20the%20average%20value%20for%20the%2012%20months%20prior%20to%20that%20(P3)%20etc%2C%20etc%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20help%20with%20all%20of%20this%20please!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2777126%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2778520%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20last%20value%20in%20a%20row%20(that%20will%20change)%20and%20calculate%20weighted%20average%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2778520%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1164043%22%20target%3D%22_blank%22%3E%40Felicity123%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EForty%20views%20as%20of%20this%20writing%2C%20no%20replies.%20I%20suspect%20it's%20because%20you've%20given%20a%20meaty%20description%20but%20not%20enough%20clarity%2C%20some%20confusion%20(e.g.%2C%20%3CEM%3E%22The%20columns%20are%20dates%20and%20will%20have%20new%20values%20added%20each%20month.%26nbsp%3BThe%20rows%20will%20change%20position%20as%20they%20are%20being%20ranked%20each%20month.%22%3C%2FEM%3E%3CLI-EMOJI%20id%3D%22lia_disappointed-face%22%20title%3D%22%3Adisappointed_face%3A%22%3E%3C%2FLI-EMOJI%3E%20is%20the%20entire%20data%20set%20comprised%20of%20dates%2C%20all%20columns%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20any%20event%2C%20you%20would%20go%20a%20long%20way%20toward%20helping%20us%20help%20you%20if%20you%20were%20to%20attach%20either%20the%20actual%20spreadsheet%20or%20(if%20the%20actual%20contains%20confidential%20data)%20a%20reasonable%20mockup%20of%20it.%20%3CU%3ENot%20an%20image%3B%20an%20actual%20spreadsheet%3C%2FU%3E%20that%20represents%20(or%20is)%20the%20actual%20data%20and%20the%20actual%20array.%20It%20needn't%20be%20all%20the%20rows%2C%20but%20it%20should%20be%20an%20adequate%20representation%20of%20the%20full%20reality.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%2C%20supplement%20that%20with%20a%20specific%20description%20of%20which%20values%20is%20it%20that%20are%20being%20assessed%20in%20terms%20of%20monthly%20change%2C%20trailing%2012%20month%20averages%2C%20etc.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E(Given%20the%20interest%20in%20trailing%2012%20month%20figures%2C%20I'm%20inferring%20that%20this%20might%20have%20to%20do%20with%20stock%20market%20data...but%20that%20is%20just%20a%20guess%3B%20if%20that's%20the%20case%2C%20I%20have%20a%20spreadsheet%20where%20I%20track%20trailing%2012%20month%20results%2C%20and%20can%20tell%20you%20it%20will%20be%20fairly%20straight%20forward%20to%20resolve%20your%20concerns.)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2778594%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20last%20value%20in%20a%20row%20(that%20will%20change)%20and%20calculate%20weighted%20average%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2778594%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3BThanks%20for%20your%20comments.%20This%20is%20my%20first%20post%20so%20am%20grateful%20for%20your%20help.%3C%2FP%3E%3CP%3EYou%20are%20correct%20in%20your%20assumptions%20regarding%20trailing%20data.%26nbsp%3B%20What%20I%20am%20trying%20to%20do%20is%20sort%20rows%20of%20data%20to%20show%20which%20are%20demonstrating%20the%20greatest%20upward%20trend%20(exponential%20rather%20than%20linear).%26nbsp%3B%20I%20have%20manually%20applied%20weightings%20but%20this%20still%20doesn't%20seem%20to%20weed%20out%20items%20with%20a%20seasonal%20bias.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EAm%20grateful%20for%20any%20solutions!%3C%2FP%3E%3CP%3EI%20have%20attached%20an%20example%20sheet.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2778749%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20last%20value%20in%20a%20row%20(that%20will%20change)%20and%20calculate%20weighted%20average%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2778749%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1164043%22%20target%3D%22_blank%22%3E%40Felicity123%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWell%2C%20from%20the%20looks%20of%20that%20spreadsheet%2C%20you're%20quite%20sophisticated%20in%20your%20use%20of%20Excel.%20In%20fact%2C%20your%20reference%20to%20%22exponential%20rather%20than%20linear%22%20suggests%20to%20me%20that%20you're%20far%20more%20sophisticated%20in%20math%20and%20statistics%20than%20many%20who%20post%20here%20(and%20more%20in%20stats%20than%20I%20am%2C%20for%20that%20matter).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20moving%20trailing%2012%20month%20average%20is%20easy%20to%20determine%20for%20any%20given%20stock%20at%20any%20point%20in%20time.%20For%20example%2C%20here's%20the%20formula%20I%20entered%20in%20cell%20Y103%2C%20pertaining%20to%20st100%20in%20your%20spreadsheet.%20I%20then%20copied%20that%20formula%20across%20the%20columns......%20Here's%20the%20formula%2C%20with%20relative%20references%2C%20so%20they%20always%20are%20showing%20the%20average%20of%20the%20prior%2012%20months.%3CSTRONG%3E%26nbsp%3B%3DAVERAGE(N101%3AY101)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20(as%20additional%20evidence%20of%20your%20level%20of%20sophistication)%20I%20noticed%20that%20you've%20implemented%20custom%20formatting%20to%20the%20numbers%2C%20rounding%20(it%20appears)%20to%20the%20nearest%20%24M%2C%20which%20is%20not%20as%20granular%20(I%20wouldn't%20think)%20as%20you%20might%20want....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyway%2C%20I%20find%20it%20hard%20to%20believe%20that%20you%20don't%20know%20how%20to%20do%20a%20trailing%20twelve%20month%20formula--%20and%20am%20frankly%20stymied%20as%20to%20exactly%20what%20the%20help%20is%20that%20you%20need.%20It%20may%20well%20be%20that%20some%20others%20among%20the%20experts%20here%20have%20more%20experience%20than%20I%20with%20this%20kind%20of%20financial%20analysis%2C%20and%20I'll%20defer%20to%20them.%20But%20if%20you%20can%20be%20patient%20with%20me%2C%20just%20humor%20me%20by%20telling%20me%20how%20(in%20words%2C%20referring%20to%20the%20data%20too)%20you'd%20assess%20exponential%20trend......etc.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2780384%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20last%20value%20in%20a%20row%20(that%20will%20change)%20and%20calculate%20weighted%20average%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2780384%22%20slang%3D%22en-US%22%3EThanks%20for%20your%20kind%20comments%20and%20for%20your%20solution.%20Unfortunately%20that%20is%20not%20what%20I%20am%20needing.%20I%20need%20the%20value%20to%20be%20referenced%20automatically%20and%20so%20that%20it%20can%20go%20in%20a%20formula%20with%20the%20logic%20-%20average(last%20value%3Alast%20value%20minus%2012mths)%20(or%20other%20period%20as%20I%20determine).%3CBR%20%2F%3EI%20can%20do%20this%20by%20inserting%20a%20cell%20and%20having%20it%20reference%20the%20cell%20for%20the%20value%2C%20but%20don't%20wish%20to%20as%20I%20want%20to%20use%20the%20value%20in%20a%20weighted%20averaging%20formula%20and%20will%20end%20up%20having%20to%20add%20another%2010%20or%20so%20columns%20to%20achieve%20the%20end%20result.%20The%20logic%20of%20the%20end%20result%20is%20something%20like%20-%20weighted%20average%20of%20last%203%20mths%2C%20weighting%3B%20average%20of%203mths%20prior%20to%20that%2C%20weighting%3B%20average%20of%206%20mths%20prior%2C%20weighting%20etc%20etc.%3CBR%20%2F%3E%3CBR%20%2F%3EBecause%20the%20actual%20sheet%20has%20over%2050K%20values%20I%20also%20want%20to%20minimise%20the%20complexity%20of%20the%20formulas%20so%20as%20to%20minimise%20calculation%20time.%3CBR%20%2F%3E%3CBR%20%2F%3ERegarding%20my%20experience%20with%20excel%3A%20I%20have%20used%20it%20for%20many%20years%20at%20an%20advanced%20level%20but%20then%20changed%20jobs%20and%20haven't%20used%20it%20for%20about%2010%20years%20so%20am%20very%20rusty!%20Ditto%20for%20my%20statistical%20analysis%20skills.%3CBR%20%2F%3E%3CBR%20%2F%3EIn%20the%20sheet%20I%20have%20used%20very%20crude%20measures%20to%20try%20to%20determine%20the%20fit%20of%20the%20data%20to%20an%20exponential%20line.%20A%20moving%20average%20is%20OK%20if%20you%20have%20a%20clear%20pattern%20but%20as%20you%20can%20see%20from%20the%20sparklines%20that%20is%20not%20the%20case%20in%20my%20data.%20So%20the%20best%20I%20can%20do%20(that%20I'm%20aware%20of)%20is%20to%20apply%20some%20exponential%20smoothing.%20Col%20C%20is%20measures%20alpha%20which%20is%20the%20exponential%20smoothing%20factor.%20If%20you%20sort%20by%20this%20column%20(largest%20-smallest)%20you%20will%20see%20that%20for%20the%20most%20part%20the%20data%20follows%20the%20exponential%20trend.%20My%20problem%20is%20that%20it%20doesn't%20sort%20it%20as%20well%20as%20I'd%20like%20so%20I%20am%20experimenting%20with%20other%20factors%20overlaying%20that%20sort%2C%20hence%20the%20formula%20I%20am%20trying%20to%20construct.%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20certainly%20open%20to%20any%20alternative%20solutions%20on%20this%20problem!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2780402%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20last%20value%20in%20a%20row%20(that%20will%20change)%20and%20calculate%20weighted%20average%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2780402%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1164043%22%20target%3D%22_blank%22%3E%40Felicity123%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20would%20no%20doubt%20be%20a%20lot%20easier%20if%20we%20were%20sitting%20down%20face-to-face%2C%20because%20we%20could%20exchange%20questions%20and%20answers%2C%20observations%20and%20clarifications%20in%20just%20a%20few%20sentences%20at%20a%20time.%20As%20it%20is%2C%20one%20of%20the%20short%20comings%20of%20communicating%20through%20exchanged%20long%20messages%20is%20that%20we%20can't%20stop%20one%20another%20mid-stream%20and%20say%2C%20%22Stop%2C%20please%20explain%20a%20little%20more%20what%20you%20mean%20by.......%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20not%20at%20all%20surprised%20that%20what%20I%20wrote%20was%20NOT%20what%20you%20were%20seeking.%20It%20was%20totally%20too%20obvious.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20I%20still%20don't%20understand%20what%20you're%20working%20so%20hard%20to%20describe.%20And%20frankly%20it%20sounds%20as%20if%20you're%20still%20working%20to%20define%20it%20for%20yourself.%20If%20we%20only%20had%20a%20white%20board%20also%2C%20in%20addition%20to%20being%20face-to-face.%20We%20could%20take%20turns%20at%20the%20white%20board%20drawing%20equations%2C%20incorporating%20new%20variables%20in%20them.....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20also%20know%20what%20the%20underlying%20reality%20is%20that%20the%20data%20are%20representing.%20I%20can%20only%20surmise.%20And%20surmising%20on%20top%20of%20vagueness%20(as%20I%20experience%20it%2C%20not%20as%20you%20transmit%20it)%20ain't%20all%20that%20productive.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20wish%20you%20well.%20My%20guess%20is%20that%20your%20rustiness%20will%20turn%20to%20polish%20quickly%20enough....after%20which%20you%20may%20want%20to%20join%20the%20ranks%20of%20people%20here%20on%20this%20site%20answering%20questions%20from%20others.%20I%20retired%20nearly%2020%20years%20ago%2C%20discovered%20this%20site%2023%20months%20ago%20through%20seeking%20the%20answer%20to%20an%20Excel%20question%20of%20my%20own...and%20have%20enjoyed%20answering%20(or%20trying%20to)%20questions%20ever%20since.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I have an extremely large data set so I think that using the offset function will be too time-consuming.  The columns are dates and will have new values added each month.

The rows will change position as they are being ranked each month.

 

Ultimately I am trying to put together a formula that will calculate a weighting value for each row.  This will be represented by a weighting value (W1) applied to the % change in average values for the last 12 months (P1) as compared to the 12 months before that (P2) combined with a weighting value (W2) applied to the % change in average values for the period P2 as compared to the average value for the 12 months prior to that (P3) etc, etc

 

I need help with all of this please!

9 Replies

@Felicity123 

 

Forty views as of this writing, no replies. I suspect it's because you've given a meaty description but not enough clarity, some confusion (e.g., "The columns are dates and will have new values added each month. The rows will change position as they are being ranked each month." is the entire data set comprised of dates, all columns? 

 

In any event, you would go a long way toward helping us help you if you were to attach either the actual spreadsheet or (if the actual contains confidential data) a reasonable mockup of it. Not an image; an actual spreadsheet that represents (or is) the actual data and the actual array. It needn't be all the rows, but it should be an adequate representation of the full reality. 

 

Then, supplement that with a specific description of which values is it that are being assessed in terms of monthly change, trailing 12 month averages, etc.

 

(Given the interest in trailing 12 month figures, I'm inferring that this might have to do with stock market data...but that is just a guess; if that's the case, I have a spreadsheet where I track trailing 12 month results, and can tell you it will be fairly straight forward to resolve your concerns.)

@mathetes Thanks for your comments. This is my first post so am grateful for your help.

You are correct in your assumptions regarding trailing data.  What I am trying to do is sort rows of data to show which are demonstrating the greatest upward trend (exponential rather than linear).  I have manually applied weightings but this still doesn't seem to weed out items with a seasonal bias.  

Am grateful for any solutions!

I have attached an example sheet.

@Felicity123 

 

Well, from the looks of that spreadsheet, you're quite sophisticated in your use of Excel. In fact, your reference to "exponential rather than linear" suggests to me that you're far more sophisticated in math and statistics than many who post here (and more in stats than I am, for that matter).

 

The moving trailing 12 month average is easy to determine for any given stock at any point in time. For example, here's the formula I entered in cell Y103, pertaining to st100 in your spreadsheet. I then copied that formula across the columns...... Here's the formula, with relative references, so they always are showing the average of the prior 12 months. =AVERAGE(N101:Y101)

 

Then (as additional evidence of your level of sophistication) I noticed that you've implemented custom formatting to the numbers, rounding (it appears) to the nearest $M, which is not as granular (I wouldn't think) as you might want....

 

Anyway, I find it hard to believe that you don't know how to do a trailing twelve month formula-- and am frankly stymied as to exactly what the help is that you need. It may well be that some others among the experts here have more experience than I with this kind of financial analysis, and I'll defer to them. But if you can be patient with me, just humor me by telling me how (in words, referring to the data too) you'd assess exponential trend......etc.

Thanks for your kind comments and for your solution. Unfortunately that is not what I am needing. I need the value to be referenced automatically and so that it can go in a formula with the logic - average(last value:last value minus 12mths) (or other period as I determine).
I can do this by inserting a cell and having it reference the cell for the value, but don't wish to as I want to use the value in a weighted averaging formula and will end up having to add another 10 or so columns to achieve the end result. The logic of the end result is something like - weighted average of last 3 mths, weighting; average of 3mths prior to that, weighting; average of 6 mths prior, weighting etc etc.

Because the actual sheet has over 50K values I also want to minimise the complexity of the formulas so as to minimise calculation time.

Regarding my experience with excel: I have used it for many years at an advanced level but then changed jobs and haven't used it for about 10 years so am very rusty! Ditto for my statistical analysis skills.

In the sheet I have used very crude measures to try to determine the fit of the data to an exponential line. A moving average is OK if you have a clear pattern but as you can see from the sparklines that is not the case in my data. So the best I can do (that I'm aware of) is to apply some exponential smoothing. Col C is measures alpha which is the exponential smoothing factor. If you sort by this column (largest -smallest) you will see that for the most part the data follows the exponential trend. My problem is that it doesn't sort it as well as I'd like so I am experimenting with other factors overlaying that sort, hence the formula I am trying to construct.

I'm certainly open to any alternative solutions on this problem!

@Felicity123 

 

This would no doubt be a lot easier if we were sitting down face-to-face, because we could exchange questions and answers, observations and clarifications in just a few sentences at a time. As it is, one of the short comings of communicating through exchanged long messages is that we can't stop one another mid-stream and say, "Stop, please explain a little more what you mean by......."

 

I'm not at all surprised that what I wrote was NOT what you were seeking. It was totally too obvious.

 

But I still don't understand what you're working so hard to describe. And frankly it sounds as if you're still working to define it for yourself. If we only had a white board also, in addition to being face-to-face. We could take turns at the white board drawing equations, incorporating new variables in them.....

 

You also know what the underlying reality is that the data are representing. I can only surmise. And surmising on top of vagueness (as I experience it, not as you transmit it) ain't all that productive.

 

So I wish you well. My guess is that your rustiness will turn to polish quickly enough....after which you may want to join the ranks of people here on this site answering questions from others. I retired nearly 20 years ago, discovered this site 23 months ago through seeking the answer to an Excel question of my own...and have enjoyed answering (or trying to) questions ever since.

@Felicity123 

I guess you need a way to dinamically develop an array calculation.
Considering you are on G column, you can play with the following AVERAGE with dinamic range using OFFSET formula.

 

=AVERAGE(OFFSET($M2,0,(COLUMN()-6)*12-11,1,12))

 

 

Thanks Juliano. I think you might be on the right track with this.
Could you please explain to me how this part of the formula works? (COLUMN()-6)*12-11,1,12)
best response confirmed by Felicity123 (Occasional Contributor)
Solution

@Felicity123 

 

OFFSET(StartingReference,0,ColumnsToDisplace,Height,Width)
If you are on column G, means that you will need to displace only 1 column from your StartingReference and then 12 columns of width (12 months range).
(Column(G)-6)*12-11=1 = ($N$2:Width)

$N$2:$Y$2

JulianoPetrukio_1-1632564269423.png

 

(Column(H)-6)*12-11=2 = ($Z$2:Width)

$Z$2:$AK$2

JulianoPetrukio_2-1632564288662.png

And so on...