Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ordering of calculations 1

Status
Not open for further replies.

Bug16

Technical User
Oct 2, 2002
22
GB
Hello,

I've been doing a lot of Crystal development recently and I'm rather curious why depending on how I order an "Or" statement depends on the results produced.

I have a Running Total Field doing a count that evaluates on a formula that does some date comparisons.

If I use:

((({Command.Due}<=CurrentDate) and isnull({Command.Approval}) and not(isnull({Command.Due}))))
or
({Command.Due}<{Command.Approval})

I get the correct result I'm expecting as my total (80,458). However, if I swap the lines around to now be:

({Command.Due}<{Command.Approval})
or
((({Command.Due}<=CurrentDate) and isnull({Command.Approval}) and not(isnull({Command.Due}))))

I get a completely different result (85). The total 85 is returned by ({Command.Due}<{Command.Approval}).

I'm just a bit confused about this because the "Or" statement should surely work with the code either way around?
 
You should always test for null first, because any Crystal test will stop if it finds a null where it wasn't looked for. So I figure that the result that you regard as correct isn't actually so.

Beyond that: split the tests into separate formulas, and see what result you get when you individually display them. This is best done using a 'boolian', a command that does not start with an 'IF' and which will return True or False.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top