| Author |
Message |
vfh-bw
Newbie
Joined: 14 Dec 2012
Online Status: Offline
Posts: 6
|

Topic: Incorrect formula? Posted: 14 Dec 2012 at 2:31am |
I have a formula that works fine until I put it in another formula. I've stared at this for hours trying to figure out what's going on, but can't figure anything out. Here are the details: - I have a shared array defined in the report header
- Everything else mentioned below is on the Detail level
- There are three other formulas the formula in question uses:
- TestA is a boolean checking data field equality
- TestB is a string manipulation of a data field based on other data fields and its own value
- TestC is a boolean checking if TestB is in the shared array
- Test (the formula in question) is a simple boolean: TestA AND TestC
- I have TestA, TestB, TestC, and Test all shown in the Detail
- As long as Test is not used in another formula, it is correct
- As soon as I put it in another formula (any formula, as far as I can tell), it becomes incorrect
- When I say 'incorrect', I mean that TestA and TestC display as True, but Test is displayed as False which it clearly should not be
- I tried doing all the logic (TestA, TestB, and TestC) in the one formula (Test) thinking that maybe it was messing something up, but that didn't help anything
I am truly stumped. Does anyone have any ideas?
|
IP Logged |
|
|
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|

Posted: 14 Dec 2012 at 8:14am |
|
I am not sure if this helps, but anything you use a formula (even inside of another formula). It will evaluate at whatever level the formula is (Report header, detail, etc.). So if you have a formula that is in the Report header that evaluate a Boolean, it may be true in the report header, but if you embed the formula in another formula in the detail section. It will evaluate the formula again for the conditions at the detail level.
To get around this issue. You may need to have the formula store the value in a shared variable and refer to the shared variable in other formulas.
I hope this helps.
|
IP Logged |
|
vfh-bw
Newbie
Joined: 14 Dec 2012
Online Status: Offline
Posts: 6
|

Posted: 14 Dec 2012 at 9:09am |
|
Thanks so much for your quick reply!
Perhaps I was not very clear, so sorry about that and I will say explicitly: all the formulas are at the Detail level. Declaring the shared array is the only thing in the Report Header, and I don't change it anywhere so that should not be an issue.
I have all 4 Test formulas (TestA, TestB, TestC, Test) next to each other in the Detail section. When Test is not referenced in any formulas, it works correctly (i.e. it's boolean TestA AND TestC). As soon as I use Test in a formula, it always evaluates as False even though all the formulas it uses (TestA, TestB, and TestC) remain the same.
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|

Posted: 14 Dec 2012 at 11:33am |
|
I have never seen that kind of behavior. Just as a test (no pun implied), can you create multiple detail sections and put the TestA, and TestC in a section prior to Test and then also put the formula (with Test in it) in a detail section after the Test section.
In theory it should not make a difference, but I have seen some odd ball results from CR.
|
IP Logged |
|
vfh-bw
Newbie
Joined: 14 Dec 2012
Online Status: Offline
Posts: 6
|

Posted: 17 Dec 2012 at 1:17am |
|
Thanks for the suggestion, but it didn't make a difference even after I did a refresh just to make sure.
If it wasn't such a complicated report that's taken me ages to get this far, I'd just start over. As it is, I have 70+ formulas and I'm not very anxious to duplicate the results with no guarantee it will even work... The weirdest thing about this (for me, anyway) is that the part that's not working shouldn't even be difficult!
Any other suggestions that might salvage all my work?
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|

Posted: 17 Dec 2012 at 5:42am |
|
Out of ideas. Boolean formulas are normally pretty easy to work with.
|
IP Logged |
|
yggdrasil
Senior Member
Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
|

Posted: 18 Dec 2012 at 3:06am |
|
Have you checked that none of the values used to evaluate Test A or B etc contain nulls?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 18 Dec 2012 at 3:44am |
somehting to consider
1. the combined formula is working corerctly but giving you an unexpected result because it is not written to do what you wanted it to
one reason why this may be happening is the way it is written is not allowing partB to exist before it is checked by partC so that portion is always returning a "false" wher you might expect a true
|
IP Logged |
|
vfh-bw
Newbie
Joined: 14 Dec 2012
Online Status: Offline
Posts: 6
|

Posted: 19 Dec 2012 at 1:32am |
|
kevlray, thank you for your time and suggestions!
I just double-checked and nothing is null (all the fields I'm using are required by the database). To be extra-sure, I went into Report Options and checked off Convert Database NULL Values to Default.
It definitely seems like somehow things aren't being evaluated in the correct order, but I can't figure out how that's happening. It seems like putting all the formulas in different Detail sections would fix that problem, would it not?
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|

Posted: 19 Dec 2012 at 5:26am |
|
You would think it work.
|
IP Logged |
|
|
|