Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

automatic zero if answer is null

Discussion in 'Information Technology' started by Pritesh_karma, Jul 28, 2006.

  1. Pritesh_karma

    Pritesh_karma
    Expand Collapse
    Guest

    In the expression builder, Im calculating a %.
    =Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2)

    but when i get Null values, the output is #NUM, I need it to be zero.
    How do i do this?
     
  2. Loading...

    Similar Threads Forum Date
    Legal Commemorating International Day of Zero Tolerance to Female Genital Mutilation Breaking News Feb 6, 2011
    Visiting Punjabi NRIs give zero, Gujaratis shower $450 billion Hard Talk Jan 21, 2011
    India Zero-Watt Smile? Breaking News Nov 13, 2010
    SciTech Zero day Flash bugs squashed by Adobe Breaking News Nov 6, 2010
    Islam Norquist and Gingrich: Debating a Mosque Near Ground Zero Interfaith Dialogues Aug 19, 2010

  3. Wayne-I-M

    Wayne-I-M
    Expand Collapse
    Guest

    Hi Pritesh

    I Take it that [5_2_1e_ii]) ([5_2_1e_i]) are number fields that may or may
    not contain data (a number). if so then use

    =Round(Sum(Nz([5_2_1e_ii]))/Sum(Nz([5_2_1e_i]))*100,2)

    For more info go to help and search on Null=Zero or Nz

    Hope this helps

    --
    Wayne
    Manchester, England.



    "Pritesh_karma" wrote:

    > In the expression builder, Im calculating a %.
    > =Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2)
    >
    > but when i get Null values, the output is #NUM, I need it to be zero.
    > How do i do this?
    >
    >
     
  4. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    the answer is probably
    =IIF(Nz(Sum([5_2_1e_i]);0)=0;0;Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2))

    I use a SafeDiv Function myself:

    Public Function SaveDiv(ByVal T As Variant, ByVal N As Variant) AS Double
    On Error Resume Next
    N= Nz(N,0)
    If N=0 Then Exit Function
    T=Nz(T,0)
    SaveDiv = T/N
    End Function

    HTH

    Pieter


    "Wayne-I-M" <WayneIM@discussions.microsoft.com> wrote in message
    news:1630AD01-34E8-43A0-A3E9-2D22A2B677DA@microsoft.com...
    > Hi Pritesh
    >
    > I Take it that [5_2_1e_ii]) ([5_2_1e_i]) are number fields that may or may
    > not contain data (a number). if so then use
    >
    > =Round(Sum(Nz([5_2_1e_ii]))/Sum(Nz([5_2_1e_i]))*100,2)
    >
    > For more info go to help and search on Null=Zero or Nz
    >
    > Hope this helps
    >
    > --
    > Wayne
    > Manchester, England.
    >
    >
    >
    > "Pritesh_karma" wrote:
    >
    >> In the expression builder, Im calculating a %.
    >> =Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2)
    >>
    >> but when i get Null values, the output is #NUM, I need it to be zero.
    >> How do i do this?
    >>
    >>




    --
    ----------------------------------------
    I am using the free version of SPAMfighter for private users.
    It has removed 4182 spam emails to date.
    Paying users do not have this message in their emails.
    Get the free SPAMfighter here: http://www.spamfighter.com/len
     
  5. Pritesh_karma

    Pritesh_karma
    Expand Collapse
    Guest

    I think i asked the question incorecctly...
    =IIf(IsError(Sum([5_2_1e_iii])/Sum([5_2_1e_i]))*100),0,Round(Sum([5_2_1e_iii])/Sum([5_2_1e_i])*100,2))
    thats what im using...
    But from my db i get values that make for a 0/0 which is undefined.

    And when i get this, the output is #NUM!

    I need it to convert it to 0.

    The expression im evaluating is, Sum([5_2_1e_iii])/Sum([5_2_1e_i]))*100
    where both 5_2_1e_ii and 5_2_1e_i are numbers.
    Please help...
    thanks.


    Wayne-I-M wrote:
    > Hi Pritesh
    >
    > I Take it that [5_2_1e_ii]) ([5_2_1e_i]) are number fields that may or may
    > not contain data (a number). if so then use
    >
    > =Round(Sum(Nz([5_2_1e_ii]))/Sum(Nz([5_2_1e_i]))*100,2)
    >
    > For more info go to help and search on Null=Zero or Nz
    >
    > Hope this helps
    >
    > --
    > Wayne
    > Manchester, England.
    >
    >
    >
    > "Pritesh_karma" wrote:
    >
    > > In the expression builder, Im calculating a %.
    > > =Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2)
    > >
    > > but when i get Null values, the output is #NUM, I need it to be zero.
    > > How do i do this?
    > >
    > >
     
  6. Pritesh_karma

    Pritesh_karma
    Expand Collapse
    Guest

    thanks.

    i dunno how to do that...
    the expression im using is in the expression builder.
    is there no way to do it there?
    Im not very clued up on writing functions.


    Pieter Wijnen wrote:
    > the answer is probably
    > =IIF(Nz(Sum([5_2_1e_i]);0)=0;0;Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2))
    >
    > I use a SafeDiv Function myself:
    >
    > Public Function SaveDiv(ByVal T As Variant, ByVal N As Variant) AS Double
    > On Error Resume Next
    > N= Nz(N,0)
    > If N=0 Then Exit Function
    > T=Nz(T,0)
    > SaveDiv = T/N
    > End Function
    >
    > HTH
    >
    > Pieter
    >
    >
    > "Wayne-I-M" <WayneIM@discussions.microsoft.com> wrote in message
    > news:1630AD01-34E8-43A0-A3E9-2D22A2B677DA@microsoft.com...
    > > Hi Pritesh
    > >
    > > I Take it that [5_2_1e_ii]) ([5_2_1e_i]) are number fields that may or may
    > > not contain data (a number). if so then use
    > >
    > > =Round(Sum(Nz([5_2_1e_ii]))/Sum(Nz([5_2_1e_i]))*100,2)
    > >
    > > For more info go to help and search on Null=Zero or Nz
    > >
    > > Hope this helps
    > >
    > > --
    > > Wayne
    > > Manchester, England.
    > >
    > >
    > >
    > > "Pritesh_karma" wrote:
    > >
    > >> In the expression builder, Im calculating a %.
    > >> =Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2)
    > >>
    > >> but when i get Null values, the output is #NUM, I need it to be zero.
    > >> How do i do this?
    > >>
    > >>

    >
    >
    >
    > --
    > ----------------------------------------
    > I am using the free version of SPAMfighter for private users.
    > It has removed 4182 spam emails to date.
    > Paying users do not have this message in their emails.
    > Get the free SPAMfighter here: http://www.spamfighter.com/len
     
  7. Pritesh_karma

    Pritesh_karma
    Expand Collapse
    Guest

    Thanks guys...
    I was a little silly...
    I found a way to do it...

    All i do is check if the number being divided by(5_2_1e_i is zero, if
    it is. i make the answer 0.

    Thanks for all your help tho.


    Pritesh_karma wrote:
    > thanks.
    >
    > i dunno how to do that...
    > the expression im using is in the expression builder.
    > is there no way to do it there?
    > Im not very clued up on writing functions.
    >
    >
    > Pieter Wijnen wrote:
    > > the answer is probably
    > > =IIF(Nz(Sum([5_2_1e_i]);0)=0;0;Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2))
    > >
    > > I use a SafeDiv Function myself:
    > >
    > > Public Function SaveDiv(ByVal T As Variant, ByVal N As Variant) AS Double
    > > On Error Resume Next
    > > N= Nz(N,0)
    > > If N=0 Then Exit Function
    > > T=Nz(T,0)
    > > SaveDiv = T/N
    > > End Function
    > >
    > > HTH
    > >
    > > Pieter
    > >
    > >
    > > "Wayne-I-M" <WayneIM@discussions.microsoft.com> wrote in message
    > > news:1630AD01-34E8-43A0-A3E9-2D22A2B677DA@microsoft.com...
    > > > Hi Pritesh
    > > >
    > > > I Take it that [5_2_1e_ii]) ([5_2_1e_i]) are number fields that may or may
    > > > not contain data (a number). if so then use
    > > >
    > > > =Round(Sum(Nz([5_2_1e_ii]))/Sum(Nz([5_2_1e_i]))*100,2)
    > > >
    > > > For more info go to help and search on Null=Zero or Nz
    > > >
    > > > Hope this helps
    > > >
    > > > --
    > > > Wayne
    > > > Manchester, England.
    > > >
    > > >
    > > >
    > > > "Pritesh_karma" wrote:
    > > >
    > > >> In the expression builder, Im calculating a %.
    > > >> =Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2)
    > > >>
    > > >> but when i get Null values, the output is #NUM, I need it to be zero.
    > > >> How do i do this?
    > > >>
    > > >>

    > >
    > >
    > >
    > > --
    > > ----------------------------------------
    > > I am using the free version of SPAMfighter for private users.
    > > It has removed 4182 spam emails to date.
    > > Paying users do not have this message in their emails.
    > > Get the free SPAMfighter here: http://www.spamfighter.com/len
     
  8. Pieter Wijnen

    Pieter Wijnen
    Expand Collapse
    Guest

    Make a new module , paste the code & save

    Then use
    =Round(SafeDiv(Sum([5_2_1e_ii]),Sum([5_2_1e_i]))*100,2)
    as the controlsource

    Pieter


    "Pritesh_karma" <pritesh01@gmail.com> wrote in message
    news:1152362689.808651.114420@s13g2000cwa.googlegroups.com...
    > thanks.
    >
    > i dunno how to do that...
    > the expression im using is in the expression builder.
    > is there no way to do it there?
    > Im not very clued up on writing functions.
    >
    >
    > Pieter Wijnen wrote:
    >> the answer is probably
    >> =IIF(Nz(Sum([5_2_1e_i]);0)=0;0;Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2))
    >>
    >> I use a SafeDiv Function myself:
    >>
    >> Public Function SaveDiv(ByVal T As Variant, ByVal N As Variant) AS Double
    >> On Error Resume Next
    >> N= Nz(N,0)
    >> If N=0 Then Exit Function
    >> T=Nz(T,0)
    >> SaveDiv = T/N
    >> End Function
    >>
    >> HTH
    >>
    >> Pieter
    >>
    >>
    >> "Wayne-I-M" <WayneIM@discussions.microsoft.com> wrote in message
    >> news:1630AD01-34E8-43A0-A3E9-2D22A2B677DA@microsoft.com...
    >> > Hi Pritesh
    >> >
    >> > I Take it that [5_2_1e_ii]) ([5_2_1e_i]) are number fields that may or
    >> > may
    >> > not contain data (a number). if so then use
    >> >
    >> > =Round(Sum(Nz([5_2_1e_ii]))/Sum(Nz([5_2_1e_i]))*100,2)
    >> >
    >> > For more info go to help and search on Null=Zero or Nz
    >> >
    >> > Hope this helps
    >> >
    >> > --
    >> > Wayne
    >> > Manchester, England.
    >> >
    >> >
    >> >
    >> > "Pritesh_karma" wrote:
    >> >
    >> >> In the expression builder, Im calculating a %.
    >> >> =Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2)
    >> >>
    >> >> but when i get Null values, the output is #NUM, I need it to be zero.
    >> >> How do i do this?
    >> >>
    >> >>

    >>
    >>
    >>
    >> --
    >> ----------------------------------------
    >> I am using the free version of SPAMfighter for private users.
    >> It has removed 4182 spam emails to date.
    >> Paying users do not have this message in their emails.
    >> Get the free SPAMfighter here: http://www.spamfighter.com/len

    >




    --
    ----------------------------------------
    I am using the free version of SPAMfighter for private users.
    It has removed 4182 spam emails to date.
    Paying users do not have this message in their emails.
    Get the free SPAMfighter here: http://www.spamfighter.com/len
     
  9. Wayne-I-M

    Wayne-I-M
    Expand Collapse
    Guest

    Can you post

    The formula you are using
    The answer you are getting
    The answer you want to get.

    It would help if you could give an example of what the fields [5_2_1e_iii]
    and [5_2_1e_i] contain.


    --
    Wayne
    Manchester, England.



    "Pritesh_karma" wrote:

    > I think i asked the question incorecctly...
    > =IIf(IsError(Sum([5_2_1e_iii])/Sum([5_2_1e_i]))*100),0,Round(Sum([5_2_1e_iii])/Sum([5_2_1e_i])*100,2))
    > thats what im using...
    > But from my db i get values that make for a 0/0 which is undefined.
    >
    > And when i get this, the output is #NUM!
    >
    > I need it to convert it to 0.
    >
    > The expression im evaluating is, Sum([5_2_1e_iii])/Sum([5_2_1e_i]))*100
    > where both 5_2_1e_ii and 5_2_1e_i are numbers.
    > Please help...
    > thanks.
    >
    >
    > Wayne-I-M wrote:
    > > Hi Pritesh
    > >
    > > I Take it that [5_2_1e_ii]) ([5_2_1e_i]) are number fields that may or may
    > > not contain data (a number). if so then use
    > >
    > > =Round(Sum(Nz([5_2_1e_ii]))/Sum(Nz([5_2_1e_i]))*100,2)
    > >
    > > For more info go to help and search on Null=Zero or Nz
    > >
    > > Hope this helps
    > >
    > > --
    > > Wayne
    > > Manchester, England.
    > >
    > >
    > >
    > > "Pritesh_karma" wrote:
    > >
    > > > In the expression builder, Im calculating a %.
    > > > =Round(Sum([5_2_1e_ii])/Sum([5_2_1e_i])*100,2)
    > > >
    > > > but when i get Null values, the output is #NUM, I need it to be zero.
    > > > How do i do this?
    > > >
    > > >

    >
    >
     

Share This Page