Coefficient of Dispersion: Create a UDF to average a range of cells

PSJupiter2

New Member
Joined
Mar 18, 2015
Messages
7
I wish to create a UDF that calculates a formula used in Mass Appraisal of Real Estate

I use MS Excel 2007, and Windows 7

This is a sample what my Data looks like:

AssessedValueSalePriceRatio = AV/SP
90881.02
90
930.97
90871.03
90940.96
90851.06
90960.94
90950.95
90980.92
901000.90
90901.00
90901.00
90980.92
90970.93
90901.00

<tbody>
</tbody>


My data ranges will be different every time I use the UDF ("n" is based on the number of data points available)


To my knowledge, there is no built-in formula for the following:

Control - Shift - Enter:
{=((AVERAGE(ABS(C2:C15-(MEDIAN(C2:C15)))))/(MEDIAN(C2:C15)))*100}


I thought a UDF would be the way to go. I am trying to accomplish the following:


Function COD(Ratio, Median)

COD= {((AVERAGE(ABS("Range of available data" - "Median of Available Data"))))/(MEDIAN("Median of Available Data"))*100}

End Function


Any help on this would be greatly appreciated! Thank You!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Isn't the coefficient of dispersion the variance divided by the mean?

=VARP(data)/Average(data)
 
Upvote 0
Isn't the coefficient of dispersion the variance divided by the mean?

=VARP(data)/Average(data)



Hi shg:

Thanks for the quick reply. Unfortunately, VARP uses the average of the data set. In the Mass Appraisal context, Coefficient of Dispersion uses the Median to test for average deviation.

Average Deviation = [ ∑ |Ratio – Median| ] / n

COD = [ (average deviation) / Median] * 100
While your formula would work for the average, it will not work for my purposes.

Thanks again for the suggestion!
 
Upvote 0
Cheap & cheerful:

Code:
Function COD(r As Range) As Double
  Dim sAdr As String
  Dim sFrm As String
  
  sAdr = r.Address
  sFrm = "average(abs(" & sAdr & " - median(" & sAdr & ")))/median(" & sAdr & ")"
  COD = r.Worksheet.Evaluate(sFrm)
End Function

Row\Col
A​
B​
C​
D​
1​
61​
0.482609​
C1: {=AVERAGE(ABS(A1:A10 - MEDIAN(A1:A10)))/MEDIAN(A1:A10)}
2​
27​
0.482609​
C2: =COD(A1:A10)
3​
65​
4​
74​
5​
90​
6​
53​
7​
14​
8​
36​
9​
5​
10​
39​
 
Upvote 0
Thank You shg!!

This worked just as intended. Now I just need to learn the components of this formula!





Cheap & cheerful:

Code:
Function COD(r As Range) As Double
  Dim sAdr As String
  Dim sFrm As String
  
  sAdr = r.Address
  sFrm = "average(abs(" & sAdr & " - median(" & sAdr & ")))/median(" & sAdr & ")"
  COD = r.Worksheet.Evaluate(sFrm)
End Function

Row\Col
A​
B​
C​
D​
1​
61​
0.482609​
C1: {=AVERAGE(ABS(A1:A10 - MEDIAN(A1:A10)))/MEDIAN(A1:A10)}
2​
27​
0.482609​
C2: =COD(A1:A10)
3​
65​
4​
74​
5​
90​
6​
53​
7​
14​
8​
36​
9​
5​
10​
39​

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
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