Average by .25

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dmkeith2@hotmail.com

    Average by .25

    I know there is an equation to come up with this but I can't think of
    it.

    I have to enter 3 different measurements an example below:

    15.25
    15.25
    15.00

    I need this to return the average of the three like this 15.25

    I used the following but I get the average of the sum:

    ([ab1] + [ab2] + [ab3])/3 this will equal 15.17

    I need it to return 15.25 It's probably a min/max function but I need
    some help

    Thanks

  • Wayne Morgan

    #2
    Re: Average by .25

    Are you trying to find the Median (value of the middle item in the list) or
    the Mode (the value that repeats most often)?

    --
    Wayne Morgan
    MS Access MVP


    <dmkeith2@hotma il.com> wrote in message
    news:1113020656 .593917.263950@ o13g2000cwo.goo glegroups.com.. .[color=blue]
    >I know there is an equation to come up with this but I can't think of
    > it.
    >
    > I have to enter 3 different measurements an example below:
    >
    > 15.25
    > 15.25
    > 15.00
    >
    > I need this to return the average of the three like this 15.25
    >
    > I used the following but I get the average of the sum:
    >
    > ([ab1] + [ab2] + [ab3])/3 this will equal 15.17
    >
    > I need it to return 15.25 It's probably a min/max function but I need
    > some help
    >
    > Thanks
    >[/color]


    Comment

    • pietlinden@hotmail.com

      #3
      Re: Average by .25

      There's some great stuff in this NG if you search for it...

      original post:


      This should do it, just put .50 as the ToWhat parameter.

      Function RoundIt (RoundMe,ToWhat )
      RoundIt = (Int(RoundMe / ToWhat + .5) * ToWhat)
      End Function

      Ron Knapper
      Newsgroups: comp.databases. ms-access
      From: r...@aol.com (Ron R K)
      Date: 1996/01/30
      Subject: Re: Rounding a dollar value

      Comment

      • dmkeith2@hotmail.com

        #4
        Re: Average by .25

        Thanks all I already found it.

        Function RoundToNearest( dblNumber As Double, varRoundAmount As Double,
        _
        Optional varUp As Variant) As Double

        Dim dblTemp As Double
        Dim lngTemp As Long

        dblTemp = dblNumber / varRoundAmount
        lngTemp = CLng(dblTemp)

        If lngTemp = dblTemp Then
        RoundToNearest = dblNumber
        Else
        If IsMissing(varUp ) Then
        ' round down
        dblTemp = lngTemp
        Else
        ' round up
        dblTemp = lngTemp + 1
        End If
        RoundToNearest = dblTemp * varRoundAmount
        End If
        End Function


        I call it in a function from a query. Thanks again

        Comment

        Working...