Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formula for Suppressing Field if duplicate in Crystal Reports

I have a view which shows data on crystal reports where I have fields like tariff,rental,shares,gross and net.My problem is if someone changes the tariff in database it would show 2 rows of the same record with different tariff which is normal behavior from database point of view but I want to suppress the field of monthly rental to 0 if the same id has different tariff or the rental is repeated in new record.

ID  Tariff  Rental
1    20       390
1    15       390

I want the field of Rental on reports to be suppressed if duplicates based on id.Currently I have used this formula in crystal report to check previous field data and suppress if duplicate.

{DatabaseField}=Previous({DatabaseField})

It is working fine but if the id is not same and the rental is repeated then also it will suppress which I don't want.I want it to suppress only for same id.

like image 516
Mohsin Avatar asked Jul 22 '12 10:07

Mohsin


People also ask

How do you avoid duplicates in Crystal Reports?

To suppress the printing of duplicate data: Select the fields in which the printing of duplicate data is to be suppressed. Select the Format/Field menu option. Check the suppress duplicate data check-box.

How do you delete duplicate records in Crystal Reports?

In the Details section, right click on the database fields that is duplicated, and select 'Insert' menu, select 'summary'. The 'Insert Summary' dialogue box appears. From the drop down list box called 'Insert a field which calculates the', select 'count'. Click OK.


2 Answers

You have to write the formula into field suppress. (No need on suppress if duplicated)

On Rental Field {ID} = previous({ID}) and {rental} = previous({rental})

If ID and Rental are same then only the Report will suppress Rental.

I guess this will work for you.

like image 149
Janarthanan Avatar answered Oct 28 '22 15:10

Janarthanan


  1. In Crystal Reports, right-click on the Details section and select Section Expert.

    1. In the Section Expert dialog box, select the X + 2 button beside the Suppress command. The check box must remain unselected for this formula to work.
    2. In the Formula Editor dialog box, create a conditional formula containing the Next function to evaluate the records for duplicate values and to suppress the Details line

    example: {Table.Databasefield}=Previous({Table.Databasefield})

like image 40
maneesh Avatar answered Oct 28 '22 13:10

maneesh