Super function

Gusher

Board Regular
Joined
Aug 21, 2011
Messages
199
This function will return the standard deviation for a named set of data over a defined period of months.

So for example if we have

Range = "START_DATE" = 30/6/2012
Range = "END_DATE" = 31/12/2015
Range = "DATA_NAME" = UK Interest Rate

Then the function will return the standard deviation of for Uk interest rates over the period June 12 - Dec 15

All the data is on sheet2. In column A we have month end dates in chronological order. In row 2 we have the data names. So for example in cell AH2 the data name is UK Interest Rate. The function must find the monthly data for the defined period from column AH and return the standard deviation.

I hope that makes sense. Many Thanks, Mark
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi,

Here's one way you can try:


  • I've assumed the column headers are in the range Sheet2!$A$2:$AZ$2
  • I've assumed the dates are in the range Sheet2!$A$3:$A$1000
  • Define a few additional named ranges as follows:
    • DATA_RANGE: =Sheet2!$A$3:$AZ$1000
    • START_ROWINDEX: =MATCH(START_DATE, Sheet2!$A$3:$A$1000)
    • END_ROWINDEX: =MATCH(END_DATE, Sheet2!$A$3:$A$1000)
    • DATA_COLUMNINDEX: =MATCH(DATA_NAME, Sheet2!$A$2:$AZ$2, 0)
  • (For the last 3, you could alternatively choose to calculate these on the sheet instead and just let the named range refer to the result cell)
  • Use the following formula for your result (replacing STDEV with whatever is the appropriate function for your use case):
    Code:
    =STDEV(
        INDEX(DATA_RANGE, START_ROWINDEX, DATA_COLUMN):
        INDEX(DATA_RANGE, END_ROWINDEX, DATA_COLUMN))
This is the basic principle, but you can adjust the ranges, and implement it however you want e.g. with or without additional named ranges, dynamically finding your last row and last column etc.

For more on how this works see for example:
 
Last edited:
Upvote 0
Hi,

Here's one way you can try:


  • I've assumed the column headers are in the range Sheet2!$A$2:$AZ$2
  • I've assumed the dates are in the range Sheet2!$A$3:$A$1000
  • Define a few additional named ranges as follows:
    • DATA_RANGE: =Sheet2!$A$3:$AZ$1000
    • START_ROWINDEX: =MATCH(START_DATE, Sheet2!$A$3:$A$1000)
    • END_ROWINDEX: =MATCH(END_DATE, Sheet2!$A$3:$A$1000)
    • DATA_COLUMNINDEX: =MATCH(DATA_NAME, Sheet2!$A$2:$AZ$2, 0)
  • (For the last 3, you could alternatively choose to calculate these on the sheet instead and just let the named range refer to the result cell)
  • Use the following formula for your result (replacing STDEV with whatever is the appropriate function for your use case):
    Code:
    =STDEV(
        INDEX(DATA_RANGE, START_ROWINDEX, DATA_COLUMN):
        INDEX(DATA_RANGE, END_ROWINDEX, DATA_COLUMN))
This is the basic principle, but you can adjust the ranges, and implement it however you want e.g. with or without additional named ranges, dynamically finding your last row and last column etc.

For more on how this works see for example:


Okay many thanks, all makes sense, I will give it a try, Mark
 
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,205
Members
448,874
Latest member
Lancelots

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