Sum IIf unable to get required result

G

Guest

i have a report with fields "Order Status" & "Cost". I have placed a txt box
in the report header & wish to display in this the sum of "Cost" where "Order
Status" = "approved". I have tried the following with no success
SUM(IIF([Order Status].Value="approved",[Cost].Value,[Cost].Value*0)
 
G

Guest

Sorry, but also add equal sign before it, and Nz to replace Null with zero
incase cose is null

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

--
Good Luck
BS"D


Ofer Cohen said:
Drop the value

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

--
Good Luck
BS"D


steve2jh said:
i have a report with fields "Order Status" & "Cost". I have placed a txt box
in the report header & wish to display in this the sum of "Cost" where "Order
Status" = "approved". I have tried the following with no success
SUM(IIF([Order Status].Value="approved",[Cost].Value,[Cost].Value*0)
 
G

Guest

Typo fix to add final ).

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

I think you can also use:
SUM(Abs([Order Status]="approved") *[Cost])

--
Duane Hookom
Microsoft Access MVP


Ofer Cohen said:
Drop the value

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

--
Good Luck
BS"D


steve2jh said:
i have a report with fields "Order Status" & "Cost". I have placed a txt box
in the report header & wish to display in this the sum of "Cost" where "Order
Status" = "approved". I have tried the following with no success
SUM(IIF([Order Status].Value="approved",[Cost].Value,[Cost].Value*0)
 
G

Guest

Thanks Duane



Duane Hookom said:
Typo fix to add final ).

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

I think you can also use:
SUM(Abs([Order Status]="approved") *[Cost])

--
Duane Hookom
Microsoft Access MVP


Ofer Cohen said:
Drop the value

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

--
Good Luck
BS"D


steve2jh said:
i have a report with fields "Order Status" & "Cost". I have placed a txt box
in the report header & wish to display in this the sum of "Cost" where "Order
Status" = "approved". I have tried the following with no success
SUM(IIF([Order Status].Value="approved",[Cost].Value,[Cost].Value*0)
 

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