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
Related
I have a data table with column Status and Extract Name and some other columns. I want to create a calculated field whose value will be true for each row if one row is true. To be clear, if there is a row where the Status is "In progress" and Extract Name is "A" I want the other rows for which this is not valid to be true (I mean that column Calculation should be true for each row), not just for that row. The picture shows that table where I was able to make only that row true.
This is the code:
IF [Status]="In Progress" AND [Extract Name]="A"
THEN TRUE
ELSE FALSE
END
How do I modify that code to get what I want, to make all rows true if there is one row that matches this condition?
use this
IF
{MAX(IF [Status]="In Progress" AND [Extract Name]="A"
THEN 1
ELSE 0
END)} >0 THEN TRUE ELSE FALSE END
If you want a demonstration, please add some sample data
You could use an Or, something like this.
IF [Status]="In Progress" OR [Status]="Completed" AND [Extract Name]="A"
THEN TRUE
ELSE FALSE
END
The OR operator would make all the rows True. The AND operator may be omitted.
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.
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.
I have a Crystal report with a table as a datasource and I want to include another table with details for the report footer.
I have two data sources in the report which are not linked, but when the selection criteria returns no rows from the main table, the results from the non-empty non-linked source are also empty.
I suspect it's doing a cross join between the two datasources, so if one is empty, that joined with another is also empty. The problem is I need my rows from the non-empty table to show in the report footer section, and they're getting suppressed by the other, empty datasource.
How can I get rows from an independent table to show in the report footer when the selection criteria and their parameter choices return an empty result set in the main table?
Thanks for your help,
-Beth
Also, I tried using a command as a datasource with sql like this:
select * from waitlist
union all
select distinct null as reportID, null as ..., lastupdated
from waitlist
but it still returns null for lastupdated and suppresses the subreport in the report footer.
I ended up setting my report datasource to a view which unioned another row to the table. I also needed to change my selection criteria so it allows this row to pass through.
Here's my datasource:
CREATE VIEW [dbo].[vw_rpt_waitlist] AS
select * from waitlist
union all
select distinct
reportID,
null as (fields...),
lastupdated,
'reserved' as countyName
from
waitlist
and here's my record selection formula:
({vw_rpt_waitlist.countyName} = {?County} or
{vw_rpt_waitlist.countyName} = "reserved") and
{vw_rpt_waitlist.reportID} = 14
I'm also suppressing the detail section if there were real rows returned:
formula = {vw_rpt_waitlist.countyName} = "reserved"
and to get the parameterized county name they selected in the page header of the report, I'm using:
dim t as string
dim c as string
if {vw_rpt_waitlist.countyName}="reserved" then
c = {?County}(1)
else
c = {vw_rpt_waitlist.countyName}
end if
t = "Waitlist by " + {#serviceTitle} + " and Waiver Need Index as of "
+ cstr({vw_rpt_waitlist.lastUpdated},"MM/dd/yyyy")
formula = t
Since the 'reserved' county always comes through, the subreports are not suppressed.
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}