Crystal Report Formular always return Boolean - crystal-reports

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}
// ^

Related

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.

Summations of values and showing result in the same row in iReport

I am using iReport designer. I have four columns in report. Value of one column will be calculated by doing sum summation and subtraction of other columns.
My result formula looks like this :
($V{cust_amount} == null ? new BigDecimal(0) : $V{cust_amount}).subtract( ($V{airlines_amount} == null ? new BigDecimal(0) : $V{airlines_amount}).subtract(($V{indi_amount} == null ? new BigDecimal(0) : $V{indi_amount}) ) )
But the result is coming just at the next row of the expected one. I am attaching a picture also.
Here the amount -15100 should come one the first row. But every value is coming just below the right row and first row is always null.
Your ternary expression seems fine - the problem is with value assignment to the variables you are using. The values are assigned after the first row is evaluated and either never change or they are assigned the same values over and over again.
You may fix value assignment to the variables but I recommend ditching the variables and using actual fields in the expression like this $F{cust_amount} - then you will be guaranteed proper value assignment before the row is printed.

How to filter rows with null values in any of its columns in SSRS

I want to filter out the output without rows containing null values or blank columns. I am using SQL Server 2012 there is no option named 'Blank' as in SS2005 where I can filter the rows. I also tried following expression but it gives me error or not showing correct output
=IsNothing(Fields!ABC.Value)!= True
=Fields!ABC.Value = ''
Please suggest the solution.
Pull up the tablix or group properties
Switch to "Filters"
Add a new filter
Set the expression to:
=IsNothing(Fields!YourFieldHere.Value)
Set the type to "Boolean" (see screenshot below) otherwise you'll get a "cannot compare data of types boolean and string" error.
Set the value to false
This works for filtering both rows and groups.
We should use the isNothing method in the Expression, change the Text to Boolean
and then Value will be "True"
for example:
Expression
=IsNothing(Fields!TestA.Value)<>True
(Expression type should be Boolean)
Operator
=
Value
=True
Edit the SQL query, so that it will not return NULL values in the column to group on, but let it return a dummy value; for example: ISNULL(columnA, 'dummy')
In the column group definition add a filter: ColumnA <> 'dummy'.

String comparisons in JasperReports expressions

A database field named income_source is queried using:
SELECT * FROM table_name WHERE income_source LIKE "salaried%"
This retrieves income_source values with a "salaried" prefix. In iReport, the PrintWhenExpression value for the field is set as:
$F{income_source}.equals("Salaried")? Boolean.TRUE:Boolean.FALSE
Why does the report output differ from the SQL output?
There are a few problems:
The value "salaried%" in the SQL differs from the value of "Salaried" in the expression.
The value "salaried%" uses the % to match all text after the letter d.
There is a bit of redundancy in the PrintWhenExpression.
Try the following expression:
$F{income_source}.startsWith( "salaried" )
Or:
$F{income_source}.trim().toLowerCase().startsWith( "salaried" )
One of those should work. You will also want to ensure Blank when null is checked. Otherwise, the expression becomes:
$F{income_source} == null ? Boolean.FALSE :
$F{income_source}.trim().toLowerCase().startsWith( "salaried" )

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}