I'm trying to run a report that has already been created and works. But when I try to run an error pops up with the 'Formula Workshop' screen and it says "the ) is missing". This is the formula displayed:
if({a.sched_firm_qty}+{a.sched_excess_qty} != 0)
then
(({a.actual_firm_qty}+{a.actual_excess_qty}) / ({a.sched_firm_qty}+{a.sched_excess_qty}))-1
else
-1
Please help
Your formula should look like
if(({a.sched_firm_qty}+{a.sched_excess_qty}) <> 0)
then
(({a.actual_firm_qty}+{a.actual_excess_qty}) / ({a.sched_firm_qty}+{a.sched_excess_qty}))-1
else
-1
I've added one additional bracket for first summary and replaced matching operator. <> is equivalent for != in CR. Hope it helps
Related
I use this code to show the sum of my bank
if {?Bank} = {Bank.sum} then {#1} else 0
I have 6 bank accounts and when the bank = Bank has operations, then I show the sumand else I do not show anything.
I do not want to show "0" in my report.
I want to show " "(space), but when I change it to " ".
When I do it, I get the error
A number is required here
How can I fix it?
In that case, use:
if {?Bank} = {Bank.sum} then ToText({#1},0) else ""
The 2nd arg indicates zero decimal points. See online documentation of the ToText() function.
One option:
if {?Bank} = {Bank.sum} then ToText({#1}) else ""
Another option is to use formatting.
{Detail A } Like '%*%'
{Detail A } Like '***'
Can I find it?
AFAIK theres no possibility to check for an asterisk * using the Like operator in Crystal Reports.
But you can user the InStr-function instead:
Instr({#Detail A}, "*") > 0
The InStr-function will return the position of the first occurrence of the character "*" in the Detail A-formula.
Means, if the character is being found, the return value is > 0.
I have a field like this, where I only want the first/latest entry to show on the Crystal report:
05/01/2018 00:00:00 pm notes
04/01/2018 00:00:00 pm more notes
03/01/2018 00:00:00 pm even more notes
Here's the code I have been trying to work with, but I get an error of "a subscript must be between 1 and the size of the array." Can someone please help point me in the right direction?
stringvar array csl;
stringvar return;
csl:=split({table.field},chr(13));
//csl[1]
if isnull({table.field}) then return:= ""
else return:=csl[1];
return;
The reason for the error is presumably because the check for null happens after the split.
I usually try to avoid using arrays/variables in Crystal Reports. Mainly because you can't group or use aggregate functions on formulas that contain variables.
So here's a solution that works with string-functions:
First Entry
If InStr({table.field}, chr(13)) > 0 Then
Left({table.field}, InStr({table.field}, chr(13)))
Else
{table.field}
Last Entry
If InStrRev({table.field}, chr(13)) > 0 Then
Right({table.field}, Len({table.field}) - InStrRev({table.field}, chr(13)))
Else
{table.field}
EDIT
To get the second line too you have to do the InStr/InStrRev two times:
First Entry
If InStr(InStr({#table.field}, chr(13))+1,{#table.field}, chr(13)) > 0 Then
Left({#table.field}, InStr(InStr({#table.field}, chr(13))+1, {#table.field}, chr(13)))
Else
{#table.field}
Last Entry
If InStrRev({#table.field}, chr(13), InStrRev({#table.field}, chr(13))+1) > 0 Then
Right({#table.field}, Len({#table.field}) - InStrRev({#table.field}, chr(13),InStrRev({#table.field}, chr(13))-1))
Else
{#table.field}
I have a section in my report and Below is my requirement to suppress it:
If scanmode and status=null (these fileds coming from database)
then i need to suppress the section.
If it is not null then i need check next condition {Status.status} >= 3 if it is >=3 then i need to check next condition {?Stack} <> "S" .
Please suggest the logic i wrote is correct or not>If wrong please modify it
Logic i wrote:
isnull({Status.scan_mode}) and isnull({Status.status})
or
{Status.status} >= 3
or
{?Stack} <> "S"
What is my doubt is here we gave or condition for every logic will it check 1st condition,if it is true then then 2nd ,if it is true then 3rd
or it will hide the section if any one of above 3 logic's is correct.
Is there any way to convert above logic to if else condition.Can we write if else in suppress condition.If yes please tell me
Please suggest me.
Write below logic in supress section
If isnull({Status.scan_mode})
then
(
if isnull({Status.status}) or {Status.status} >= 3 then
(
if {?Stack} <> "S"
then
true
)
)
else false
if isnull({Status.scan_mode}) and isnull({Status.status}) then true
else if Scanmode = 'C' or Scanmode = 'D' then true
else if {Status.status} >= 3 or {?Stack} <> "S" then true
else false
I hope this helps
I just started learning Crystal Reports, and am using the below formatting formula:
local numberVar result;
if GroupName ({SCD_CUSTOMER.NAME}) = "32 Bar Blues, LLC" Then
(
result = round({PTS_PRI_ORDER_PRICING.SELLING_PRICE}, 2);
result;
)
Else defaultAttribute
For a while I didn't have the Else statement there, and I couldn't understand why the report would round ALL selling_price values, rather than just those for 32 Bar Blues, LLC.
Sticking the Else in fixed my issue, but I still don't understand it. Why is the round being executed when it should never even be looked at for scd_customer.name != 32 Bar Blues, LLC? What am I missing here?
There are couple of things possible first one is you are comparing string so it can be possible you have written wrong string name
Its a blind guess try to use below statement in "IF"
if GroupName ({SCD_CUSTOMER.NAME}) == "32 Bar Blues, LLC" Then