-
May 3rd, 2016, 12:49 PM
#1
Need to add a restriction to a current formula, but not quite sure how to do it!
Hi everyone. I am currently using Cyrstal Reports 2008 Version 12.3.0.601. It is important for you to understand that I am a novice at this, so please forgive my stupidity. I currently have a Formula that does this:
IF {ARTRNDETAIL.NetSalesValue} = 0
THEN 0
ELSE ({#GrossProfit}/{#NetSalesValueYTD}*100)
It works as needed, but I need to create another formula that does the same thing as above, but I need to add this restriction to it:
{ARTRNDETAIL.TrnMonth} = Maximum({?Period})
I tried to do it in this manner:
{ARTRNDETAIL.TrnMonth} = Maximum({?Period}) AND
IF {ARTRNDETAIL.NetSalesValue} = 0
THEN 0
ELSE ({#GrossProfit}/{#NetSalesValueYTD}*100)
But it doesn't work. (States "A Boolean is required here" but I'm not sure where or how.) It's probably obvious to many of you, but I cannot seem to figure it out. Any help is greatly appreciated. Thanks in advance.
-
May 4th, 2016, 10:17 AM
#2
Re: Need to add a restriction to a current formula, but not quite sure how to do it!
The error "A Boolean is required here" is returned because a formula is similar to a database field in that is must be of 1 and only 1 data type. The statement {ARTRNDETAIL.TrnMonth} = Maximum({?Period}) returns a Boolean (true/false) value, while the if-then-else portion of the statement would return a numeric value. Not sure what you are attempting to do here, but make the code work you could try changing to
Code:
IF {ARTRNDETAIL.TrnMonth} = Maximum({?Period}) THEN
IF {ARTRNDETAIL.NetSalesValue} = 0 THEN
0
ELSE ({#GrossProfit}/{#NetSalesValueYTD}*100)
ELSE
// when {ARTRNDETAIL.TrnMonth} <> Maximum({?Period})
0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|