How to Write a Selection Criteria Formula - crystal-reports

I am new to Crystal Rpts...I am using crystal 13 on a windows 7 pro 64-bit. I am trying to write a selection criteria formula for a basic report. Here is what I am trying to say..
if the status.temp_date is empty (null) but the status.perm_date has a date (not null)
then pull all records where that status.perm_date is < the projectedstatus.projected_date and a status.perm_date is in a date range for the projectedstatus.projected_date (projectedstatus.projected_date{?start date} to projectedstatus.projected_date {?end date})
also pull
all records with a projectedstatus.projected_date that is between the projectedstatus.projected_date {?start date} and projectedstatus.projected_date {?end date}
here is what I wrote:
(isnull({status.temp_date}) and not isnull({status.perm_date}) and
{status.perm_date} < {projectedstatus.projected_date} and
{projectedstatus.projected_date} in {?sdate} to {?edate}
this is only returning records with perm.date ....no currently active records with no perm.date and a projected.dates with in the selected date range
so then I tried:
if(isnull({status.temp_date})) and not isnull({status.perm_date}) then
{status.perm_date} < {projectedstatus.projected_date} and
{projectedstatus.projected_date } in {?sdate} to {?edate} and
if (isnull({status.temp_date})) and isnull({status.perm_date}) and not isnull
({projectedstatus.projected_date}) then
{projectedstatus.projected_date} in {?sdate} to {?edate}
now I'm not getting any records.....
any suggestions?

I have used crystal reports long back, Selection formula what ever is written gets checked for each row and if the expression you wrote results in true then that record gets included. if returns false then that record will not be included.
from your code snippet you have to use the if else if conditions so that every condition is getting handled one single boolean true or false should result from there
one more way you can do is, if it is easy to write the the negative case where row should not come then , simply write that condition in if and return false also have else condition with return as true so that for all other conditions rows get selected
like example,
if ((isnull({temp.date}) and not isnull({perm.date}) and (( {perm.date} < {projected.date} and NOT {projected.date} in {?sdate} to {?edate}) OR ({perm.date} > {projected.date}))) then FALSE ELSE TRUE
Please check syntax once.

Related

IIF or IF statement in Tableau

I am trying to write a IIF statement in Tableau to check if a condition passes. If it fails the condition, I want it to show "No values" rather than filtering out the row.
Given below is the IIF statement I am using:
IIF(([Average monthly count] > [Today]),[Average monthly count],"No values in the range")
As mentioned in comments, in Tableau isn't possible to return two different data types in IF or IIF statements, so if you really need to pass a string like "no values in range", you must return a string in true case. This can be done using the function STR as follows:
IIF(([Average monthly count] > [Today]),STR([Average monthly count]),"No values in the range")
Another option may be just return NULL in false case.
IIF(([Average monthly count] > [Today]),[Average monthly count],NULL)

hide rows with zero value -- crystal reports

I have the following table in Crystal Reports 2010:
Name------------Number----Line----Price-----InvoiceNum
CustomerX-------800---------2------$100----------1
CustomerX-------800---------4------$0-------------1
CustomerX-------800---------4------$0-------------1
CustomerX-------800---------4------$900----------1
CustomerX-------800---------3------$0-------------1
CustomerX-------800---------3------$0-------------1
CustomerX-------800---------3------$1900---------1
CustomerX-------800---------2------$0-------------1
CustomerX-------800---------2------$0-------------1
I want to suppress the rows that are duplicates and have $0 value, so I need somethings like this:
CustomerX-------800---------2------$100----------1
CustomerX-------800---------4------$900----------1
CustomerX-------800---------3------$1900---------1
At section expert if I use this formula for suppressing it will hide all rows that have Price as $0 value.
if {#Price}=0 then true else false
But I only want to hide the $0 value if there are duplicate Line numbers for same InvoiceNum.
I also tried this:
if ({#Price}=0 and {#Price}=previous({#Price})) then true else false
but it would not remove all of the zero-values, just a part.
Go Report >Selection Formula>Record then Select your Fields As is
{Supplier.ClosingBalance} <>0

Crystal reports selecting record that contain empty strings or "null"

I have a report that for a field called JobNo there are some records that have "null" as the the cell value and some that have an empty string "". there is another field called AccntNo that im also selecting by in the same selection formula.
This is what i have tried without success in the selection formula for crystal reports.
{accnt.accno} = "7015" and
{accnt.jobno} = "" or {accnt.jobno} isnull
any help is apreciated
Selection formula doesn't work as expected, sometimes.
I suppose that this will work
{accnt.accno} = "7015" and
( isnull({accnt.JobNo}) or {accnt.jobno} = "" )
First of all I put parenthesis on 'or' clause.
But, the strangest thing, is that isnull clause must be evaluated before other comparison clauses.

Crystal Report Formular always return Boolean

iN my Crystal Report i have two columns of currency data types. I want to add a formular to the column a . i.e "WHEN A CURRENCY IN A is > THAN B, THEN The value of A should euqal the value of B ". I wrote my formula as below
currencyVar formular := {ProcName.coll};
IF({ProcName.coll} > {ProcName.ref})
Then
formular = {ProcName.ref}
AND
IF({ProcName.coll} > {ProcName.ref})
Then
{ProcName.coll}= {ProcName.ref}
Both yielded the same boolean values.When I saved and named the formula above, i then insert the formula to my column . However, the result are all boolean True/False. I am ot sure how this happened i check the data type of the formula is indicating boolean as well.
This is because you're testing equality not assigning the value as you wish to do. Change your last line to a statement of assignment by adding a colon before the equal sign:
...
formular := {ProcName.ref}
// ^

Crystal reports sum

I need the sum of two database fields. I use this formula field :
{dbfield1}+{dbfield2}
and if dbfield1 and dbfield2 are != from null in database the sum is showing, but if the dbfield1 or dbfield2 are missing(no data) the formula field is not showing.
how can I manage this in Crystal report?
Two options :
Either use the Convert Database Fields to Null option under Report Options, which will convert the numeric field nulls to zero and make your sum work, or
Use the IsNull function in your formula :
If IsNull({dbfield1}) And IsNull({dbfield2}) Then
0
Else If IsNull({dbfield1}) Then
{dbfield2}
Else If IsNull({dbfield2}) Then
{dbfield1}
Else
{dbfield1}+{dbfield2}