DStDev, DStDevP Functions Example
The following example returns estimates of the standard deviation for a population and a population sample for orders shipped to the United Kingdom. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which the ShipCountry is UK.
Dim dblX As Double, dblY As Double
' Sample estimate.
dblX = DStDev("[Freight]", "Orders", "[ShipCountry] = 'UK'")
' Population estimate.
dblY = DStDevP("[Freight]", "Orders", "[ShipCountry] = 'UK'")
The next example calculates the same estimates by using a variable, strCountry
, in the criteria argument. Note that single quotation marks (') are included in the string expression, so that when the strings are concatenated, the string literal UK
will be enclosed in single quotation marks.
Dim strCountry As String, dblX As Double, dblY As Double
strCountry = "UK"
dblX = DStDev("[Freight]", "Orders", _
"[ShipCountry] = '" & strCountry & "'")
dblY = DStDevP("[Freight]", "Orders", _
"[ShipCountry] = '" & strCountry & "'")