iif Statement not working when there is a zero vlaue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MNNovice
    Contributor
    • Aug 2008
    • 418

    iif Statement not working when there is a zero vlaue

    Hi,
    My report (rBalance) is based on a query (q3). q3 is based on two other queries (q1) & (q2)

    q1 has two figures: Budget amount and Draw amount
    q2 has one figure: Authorized amount. This is a calculated field. Budget amount X Ratio %

    To get to balance amount. i am using Authorized Amount - Draw Amount.

    Everything works except when there is not Draw Amount.

    I tried, "iif(([AuthorizedAmoun t]-[DrawAmount]) <> 0, [AuthorizedAmoun t], ([AuthorizedAmoun t-[DrawAmount]))

    I know this should be simple but I just couldn't get it to work. Please help. Thanks.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    Is draw amount actually 0 (zero) or is it Null. There is a huge difference between the two....

    If DrawAmount is Null (even if it is not), you can use the following:

    Code:
    [AuthorizedAmount] - Nz([DrawAmount], 0)
    Hope this helps.

    Comment

    • MNNovice
      Contributor
      • Aug 2008
      • 418

      #3
      Thanks. But it didn't work either. Here is the actual expression I used.

      Balance: IIf([FTAAmount]-Nz([SumOfiAmountECH O],0),[FTAAmount],([FTAAmount]-[SumOfiAmountECH O]))

      The balance comes out okay where there is no value for SumOfiAmountECH O. But if I have a value for this field the balance is incorrectly showing up as FTAAmount instead of FTAAmount - SumOfiAmountECH O.

      Thanks for your time.

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3662

        #4
        There should be no need for the IIf statement. The Nz() function precludes a need for it.

        Comment

        • MNNovice
          Contributor
          • Aug 2008
          • 418

          #5
          Got it. Thank you. Much appreciated.

          Comment

          Working...