All,
I've scoured the internet looking for an answer to this problem, but am left unsatisfied. Maybe i'm over complicating things, & I hope someone can help me out.
I currently have a spreadsheet that is updated on a monthly basis where I need to calculate the median of the last 7 reportable (i.e. non-zero) values prior to my current data. I cannot simply "remove blanks" as I have additional pertinent information on adjacent columns. Here's a sample dataset:
[TABLE="width: 300"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1/1/16[/TD]
[TD]1[/TD]
[TD]0.2[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2/1/16[/TD]
[TD]5[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3/1/16[/TD]
[TD]15[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4/1/16[/TD]
[TD][/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]5/1/16[/TD]
[TD][/TD]
[TD]15[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]6/1/16[/TD]
[TD]4[/TD]
[TD]24[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]7/1/16[/TD]
[TD]5[/TD]
[TD]17[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]8/1/16[/TD]
[TD][/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]9/1/16[/TD]
[TD][/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]10/1/16[/TD]
[TD][/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]11/1/16[/TD]
[TD][/TD]
[TD]15[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]12/1/16[/TD]
[TD]0.5[/TD]
[TD]56[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]1/1/17[/TD]
[TD][/TD]
[TD]54[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]2/1/17[/TD]
[TD]11[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]3/1/17[/TD]
[TD]13[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]4/1/17[/TD]
[TD]17[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD]Median of last 7 value[/TD]
[TD]FORMULA? [/TD]
[TD]9[/TD]
[/TR]
</tbody>[/TABLE]
Assuming 4/1/17 is my current dataset, I need to calculate the median of the last 7 data points in column B prior to 4/1/17 (i.e. last 7 values from 1/1/16 through 3/1/17 [rows 1 through 15]) to compare to my current data. I am using the array formula:
=MEDIAN(INDIRECT("B"&LARGE(ISNUMBER(B1:B15)*ROW(B1:B15),7)&":B15"))
which ultimately calculates the correct result, but that array formula is cumbersome. I also have thousands of these discrete datasets where the "B" in INDIRECT("B" and the ":B15") at the end of the formula don't carry when I copy from row-to-row and column-to-column. Is there a more elegant (preferably non-array) formula I can use that I haven't thought of?
As an added bonus, is there any way I could make the formula automatically update as I insert data for 5/1/17 and beyond (i.e. insert data into row 17)?
Thank you for all of the help I've gotten over the years from the experts at Mr.Excel.
I've scoured the internet looking for an answer to this problem, but am left unsatisfied. Maybe i'm over complicating things, & I hope someone can help me out.
I currently have a spreadsheet that is updated on a monthly basis where I need to calculate the median of the last 7 reportable (i.e. non-zero) values prior to my current data. I cannot simply "remove blanks" as I have additional pertinent information on adjacent columns. Here's a sample dataset:
[TABLE="width: 300"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1/1/16[/TD]
[TD]1[/TD]
[TD]0.2[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2/1/16[/TD]
[TD]5[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3/1/16[/TD]
[TD]15[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4/1/16[/TD]
[TD][/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]5/1/16[/TD]
[TD][/TD]
[TD]15[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]6/1/16[/TD]
[TD]4[/TD]
[TD]24[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]7/1/16[/TD]
[TD]5[/TD]
[TD]17[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]8/1/16[/TD]
[TD][/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]9/1/16[/TD]
[TD][/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]10/1/16[/TD]
[TD][/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]11/1/16[/TD]
[TD][/TD]
[TD]15[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]12/1/16[/TD]
[TD]0.5[/TD]
[TD]56[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]1/1/17[/TD]
[TD][/TD]
[TD]54[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]2/1/17[/TD]
[TD]11[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]3/1/17[/TD]
[TD]13[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]4/1/17[/TD]
[TD]17[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD]Median of last 7 value[/TD]
[TD]FORMULA? [/TD]
[TD]9[/TD]
[/TR]
</tbody>[/TABLE]
Assuming 4/1/17 is my current dataset, I need to calculate the median of the last 7 data points in column B prior to 4/1/17 (i.e. last 7 values from 1/1/16 through 3/1/17 [rows 1 through 15]) to compare to my current data. I am using the array formula:
=MEDIAN(INDIRECT("B"&LARGE(ISNUMBER(B1:B15)*ROW(B1:B15),7)&":B15"))
which ultimately calculates the correct result, but that array formula is cumbersome. I also have thousands of these discrete datasets where the "B" in INDIRECT("B" and the ":B15") at the end of the formula don't carry when I copy from row-to-row and column-to-column. Is there a more elegant (preferably non-array) formula I can use that I haven't thought of?
As an added bonus, is there any way I could make the formula automatically update as I insert data for 5/1/17 and beyond (i.e. insert data into row 17)?
Thank you for all of the help I've gotten over the years from the experts at Mr.Excel.