Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking conditions

Status
Not open for further replies.

crystalreport85

Programmer
Sep 27, 2010
51
CA
In my Crystal report 8.5 I am trying to check some condition and display the result in report section.

First I want to find the total sale of each month by saleman. And in the report section
Condition 1: if the cust_type is xx then grand total that perticular record.
condition 2: if the cust_type is yy and salesman = aaa then print the grand total in the report section.

condition 3: if the cust_type is yy and salesman <> aaa then print the grand total

How to check these conditions?
I tried using whilereadingrecords(formula) in detail section to sum the sales for each month . and used whileprintingrecords in report section to print the result. My problem is using shared variable since I am using 'Whilereadingrecords'
And I getting wrong answer. first month it gives correct ans but next month it is not adding proberly


Thanks in advance

 
Use a running total. The use of Crystal's automated totals is outlined at FAQ767-6524.


[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Thank you so much. It worked. One more thing If the condition is false I want to make the field data zero. How to do it ?
Thank you
 
A running total should add to zero if it finds nothing with the condition. But if it comes out as null, have a formula field to test it. Something like
Code:
If IsNull(@Total) then 0
else @Total
Note that you must always test for nulls first, otherwise the result will be blank

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
i need to return '0' when the running total is zero.. is there any way doing it in the running total field.
Thank you
 
Can you clarify what database fields can be null? Is it sales? If so, use a formula like this:

//{@sales}:
if isnull({table.sales}) then
0 else
{table.sales}

You might want to try inserting a crosstab that uses {table.salesdate} as the column field->options->print on change of month. Then add {table.customertype} as your first row field, and then add the following formula as your second row field:

if {table.customertype} = "yy" then
{table.salesperson}

Add sum of {@sales} as your summary field. If you don't have duplicating records, the crosstab would be a good solution. Place it in the report footer and suppress other sections.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top