Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

IIF and Sum on an Access report

Options
  • 11-07-2005 4:04pm
    #1
    Registered Users Posts: 420 ✭✭


    I am trying to get some info on an Access 2000 report that shows me the total value of customers who have paid for a product.
    The field which shows paid or not is a checkbox.

    I am trying to show:

    The number of units - =Count([Tester_ID])
    The total € of units ordered - =Sum([price])
    The number of units paid for - =Count(IIf([paid]="Yes",0))
    The total € of units paid for - =IIf([paid]="Yes",Sum([price]))


    This is all coming from a query which first filters by a month.
    The only field i cannot populate is the total € of units paid for.
    It looks like i am missing a false criteria but if i put
    =IIf([paid]="Yes",Sum([price]),0) the result is zero.
    I would just multiply units by a value but all the units are not standard price.

    Can anyone help me out on this hot day?


Comments

  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I'm not sure if it'll let you do this but I think you want the SUM to be outside the IIF i.e.
    SUM(IIF([paid]="Yes",[price],0))


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Yup. Put the sum outside.

    Alternately, put the IIF into the Query, and just SUM the value in the report.


  • Registered Users Posts: 420 ✭✭RustySpoon


    Thanks for the help, worked a treat :)


  • Registered Users Posts: 1,393 ✭✭✭Inspector Gadget


    RustySpoon:

    In case you didn't spot it, Iif() takes three operators, not two:
    ReturnValue = IIf({expression to evaluate as boolean}, {return this if true}, {return this if false})
    

    Gadget


Advertisement