Access combination of IIf and Sum functions needed... Please help!

K

Koral

I have a Sum function in a Wizard generated report:
=Sum([Amount])

Now, I want to create another text box, where the SUM should base on the
VALUE OF ANOTHER FIELD:
The [Amount] values should be summed up ony where the [Payment Status] field
contains the value "Invoiced". I get error whatever I have tried!

If I could success, I would like to add another SUM box for the case where
the referenced field contains another value.

Can anybody please help?

Involved fields, values and conditions:
Field: [Payment Status]
Possible values: "Payed", "Pending" and "Invoiced"
Condition: [Payment Status] field value = "Invoiced"
Task: Calculaıte and output all the values of [Amount] field where the
[Payment Status] field of the same record is "Invoiced"

Note: The report is already in an outlined structure. That is, the records
shown are grouped under an [Outsourcer] field. That is, the SUM should
involve only those entries that are listed under that outsourcer.
There is the following automatically generated footer above the existing SUM
function:
="Summary for " & "'Outsourcer' = " & " " & [Outsourcer] & " (" & Count(*) &
" " & IIf(Count(*)=1;"detail record";"detail records") & ")"
 
M

Marshall Barton

Koral said:
I have a Sum function in a Wizard generated report:
=Sum([Amount])

Now, I want to create another text box, where the SUM should base on the
VALUE OF ANOTHER FIELD:
The [Amount] values should be summed up ony where the [Payment Status] field
contains the value "Invoiced". I get error whatever I have tried!

If I could success, I would like to add another SUM box for the case where
the referenced field contains another value.

Can anybody please help?

Involved fields, values and conditions:
Field: [Payment Status]
Possible values: "Payed", "Pending" and "Invoiced"
Condition: [Payment Status] field value = "Invoiced"
Task: Calcula?te and output all the values of [Amount] field where the
[Payment Status] field of the same record is "Invoiced"


Use this kind of expression in the group (or report) footer
text box:
=Sum(IIf([Payment Status] = "Invoiced". Amount, 0)
 
K

Koral

Thank you marsh. Yes, that proved to be the solution, with another closing
parenthesis at the end.

After trying many suggestions and getting a lot of syntax errors, I've found
the answer in the reply of Duane Hookom to steve2jh for his question "Sum IIf
unable to get required result":

SUM(IIF([Order Status]="approved",[Cost],0))

Tailored for my case, it reads:
=SUM(IIF([Payment Status]="Invoiced",[Amount],0))
and functions great!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top