Sunday, January 16, 2011

Suppress if duplicated

Hi

Usually, when you make SQL queries, you don`t want to see "duplicated" rows.
You work very hard from bottom all the way to top to make sure that every row in your query has only unique values.
Sometimes you know you there is not option other then getting a duplicated value.

Crystal Reports comes to the rescue with the "Suppress if duplicated" option.
You can do a simple click on the option to select it on a field and by that only the field will be suppressed if duplicated, but usually you want to suppress an entire details row (somewhat like group by in an SQL query).
For this we have functions.
Right click on the sections and select "Section Expert . . . ".
Choose the section you wish to suppress (usually the details section) and select the option "Suppress if Duplicated".
Click on the "X-2" button (Formula workshop) and enter the formula as follow:
{table.field} = Previous({table.field}).

This will suppress the details row every time the previous row has the same table field value.

Good luck
Shahar

4 comments:

  1. thank you for sharing this information it helps me increase my knowledge about SQL.

    www.triciajoy.com

    ReplyDelete
  2. What if I enter this formula in the Section Expert and I still get duplicates?

    ReplyDelete
  3. What if I enter this formula in the Section Expert and I still get duplicates?

    ReplyDelete
  4. You are my hero...was trying everything to get this to work. Thank you Thank you Thank you!

    ReplyDelete