View Full Version : a few syntax problems in my equations


antonyx
10-04-2007, 10:20 AM
a few questions on the syntax of some arithmetic im doing in my reports..

are the two statements below correct?


=Sum(IIf([fkAccountTypeID]=2,Nz([JobTdCp],0)+(IIf([fkAccountTypeID]=2,Nz([JobTdExtra],0))


=Sum(IIf([fkAccountTypeID]=2,Nz[JobTdFare],0)+(IIf([fkAccountTypeID]=2,[JobTdCp],0)+(IIf([fkAccountTypeID]=2[JobTdExtra]))

KenHigg
10-04-2007, 10:28 AM
For starters - I think you're missing some parens...

:)
ken


edit: Then on the first one at least, it looks like you've missed putting in the false part of you iif()'s

boblarson
10-04-2007, 10:30 AM
For starters - I think you're missing some parens...

:)
ken

And I couldn't see any FALSE outputs in both IIf statements.

antonyx
10-04-2007, 10:52 AM
lol.. i know the score..


the only reason i am just looking for a solution is because i am sooo busy right now.. i dont even have time to post this..

seriously..

if one of you kind gentlemen could fix the syntax on those statements because i am sure they are wrong.


please..?

boblarson
10-04-2007, 10:59 AM
I THINK this is it:

=Sum(IIf([fkAccountTypeID]=2,Nz([JobTdCp],0)+(IIf([fkAccountTypeID]=2,Nz([JobTdExtra],0),0))))


=Sum(IIf([fkAccountTypeID]=2,Nz[JobTdFare],0)+(IIf([fkAccountTypeID]=2,[JobTdCp],0)+(IIf([fkAccountTypeID]=2[JobTdExtra]),0))))

antonyx
10-04-2007, 01:33 PM
hi, thank you bob.. you have got me on the right track (i hope!)

basically all i need to do now is the following.


i want this:

=Sum(IIf([fkAccountTypeID]=2,Nz([JobTdCp],0)+(IIf([fkAccountTypeID]=2,Nz([JobTdFare],0)+(IIf([fkAccountTypeID]=2,Nz([JobTdExtra],0)))))))

minus this:

=Sum((IIf([fkAccountTypeID]=1,[JobTdFare],0)*[JobCom])+(IIf([fkAccountTypeID]=2,[JobTdFare],0)*[JobCom]))

im trying to use this.. but gettin completely the wrong results.

=Sum(IIf([fkAccountTypeID]=2,Nz([JobTdCp],0)+(IIf([fkAccountTypeID]=2,Nz([JobTdFare],0)+(IIf([fkAccountTypeID]=2,Nz([JobTdExtra],0))-((IIf([fkAccountTypeID]=1,[JobTdFare],0)*[JobCom])-(IIf([fkAccountTypeID]=2,[JobTdFare],0)*[JobCom])))))))


also.. if i am using to many brackets.. im sorry.. the first two are gettin me the results i want.. and im just kind of guessing the number of brackets at the end...

boblarson
10-04-2007, 01:38 PM
Wouldn't it just be taking the two exactly as they are individually written but the one that you are subtracting doesn't have the = sign in front:

=Sum(IIf([fkAccountTypeID]=2,Nz([JobTdCp],0)+(IIf([fkAccountTypeID]=2,Nz([JobTdFare],0)+(IIf([fkAccountTypeID]=2,Nz([JobTdExtra],0))))))) - Sum((IIf([fkAccountTypeID]=1,[JobTdFare],0)*[JobCom])+(IIf([fkAccountTypeID]=2,[JobTdFare],0)*[JobCom]))

antonyx
10-04-2007, 01:46 PM
ok let me try that

antonyx
10-04-2007, 01:47 PM
yes, that seems to work.. thank you bob.. you have shown me the light yet again.

boblarson
10-04-2007, 01:54 PM
yes, that seems to work..

Good, glad that works.