Need URGENT help with populating an array based on Count

nld08

New Member
Joined
Mar 14, 2014
Messages
2
Hi all,

I am trying to calculate the Standard Deviation of an array. However, to populate the array, I have the following:

CountNumber 1CountNumber 2CountNumber 3
110022003300

<tbody>
</tbody>

For example, this above means that there are 1 100's, 2 200's, 3 300's. I would ideally like to populate an array that is {100,200,200,300,300,300} based on those 6 columns that provide a count and a number. Then, I would like to calculate the standard deviation based on those (in this case it is 74.5).

Does anyone know how to do this without VBA? Thank you so so much! Any help / tips would be greatly appreciated...
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
ABCDEFGHI
1Count_1Num_1Count_2Num_2Count_3Num_3Total_Count6
2110022003300Mean233.3333
3Variance5555.556
4Std Dev74.5356

<tbody>
</tbody>

CellFormula
Total_Count=SUM(Count_1,Count_2,Count_3)
Mean=((Count_1 * Num_1) + (Count_2 * Num_2) + (Count_3 * Num_3)) / Total_Count
Variance=((Count_1*((Mean - Num_1)^2)) + (Count_2*((Mean - Num_2)^2)) + (Count_3*((Mean - Num_3)^2))) / Total_Count
Std Dev=Variance^0.5

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
For a single cell formula solution, assuming that A1:F2 contains the data, maybe...

=STDEVP(LOOKUP(ROW(INDIRECT("1:"&SUMIF(A1:F1,"Count",A2:F2))),MMULT(N(OFFSET(A2:F2,,TRANSPOSE(ROW(INDIRECT("1:"&COLUMNS(A2:F2)/2)))*2-2,,1)),(ROW(INDIRECT("1:"&COLUMNS(A2:F2)/2))<=TRANSPOSE(ROW(INDIRECT("1:"&COLUMNS(A2:F2)/2))))+0)-N(OFFSET(A2:F2,,TRANSPOSE(ROW(INDIRECT("1:"&COLUMNS(A2:F2)/2)))*2-2,,1))+1,N(OFFSET(A2:F2,,TRANSPOSE(ROW(INDIRECT("1:"&COLUMNS(A2:F2)/2)))*2-2+1,,1))))

...which needs to be confirmed with CONTROL+SHIFT+ENTER. Adjust the ranges A1:F1 and A2:F2, accordingly. Note, however, this formula is resource-intensive. So it will slow down your spreadsheet if it's copied to many rows.

Hope this helps!
 
Upvote 0
Very nice, Domenic.

Actually you can shorten that somewhat (and remove a large part of the volatility) by taking advantage of the fact that the lookup_vector does not need to be re-dimensioned (each element can simply be duplicated):

=STDEVP(LOOKUP(ROW(INDIRECT("1:"&SUMIF(A1:F1,"Count",A2:F2))),MMULT(0+(ROW(INDIRECT("1:"&COLUMNS(A1:F1)))>=TRANSPOSE(ROW(INDIRECT("1:"&COLUMNS(A1:F1))))),TRANSPOSE(IF(A1:F1="Count",A2:F2,0)))-TRANSPOSE(IF(A1:F1="Count",A2:F2,0))+1,IF(A1:F1<>"Count",A2:F2,B2:G2)))


Regards
 
Upvote 0
XOR LX, nicely done! In using your method, we can get rid of the volatile function INDIRECT...

=STDEVP(LOOKUP(ROW(INDEX(A:A,1):INDEX(A:A,SUMIF(A1:F1,"Count",A2:F2))),MMULT(0+(TRANSPOSE(COLUMN(A2:F2))>=COLUMN(A2:F2)),TRANSPOSE(IF(A1:F1="Count",A2:F2,0)))-TRANSPOSE(IF(A1:F1="Count",A2:F2,0))+1,IF(A1:F1<>"Count",A2:F2,B2:G2)))

Cheers!
 
Upvote 0
Ah, yes, of course! Good stuff! And not a trace of volatility left!!

Like the idea of this LOOKUP construction to generate the required array, by the way.

Cheers
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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