Search code examples
c#sql-serverwpfvisual-studiocrystal-reports

Add a conditional row in crystal report


I am working on a C# app that will print bills/receipts with a thermal printer. I am using Crystal Reports for generating reports/bills.

I want the report to have 4 fields (Item Name, Quantity, Amount, Discount). There might be a discount sometimes otherwise not. The format of this report should be something like this (For reference also see this)

| Item Name | Qty | Amount$ |
|---------------------------|
| Abc       |  1  |  100    |
| You Saved 4$    |         |
|---------------------------|
| Def       |  1  |  50     |
|---------------------------|

As from the table, there was a discount for Item = Abc, so the discount row (You saved 4$) is there, for the Item=Def there was no discount so the row is not there.

How can i achieve a result like this?

Edit Solved.


Solution

  • No need for an additional column. Right-click the detail section and select 'Insert Section Below. This should result in Detail a (where you place the normal content) and Detail b section (where you place the discount info.

    In the Suppress expression for Detail b have an expression such as:

    {Discount} = 0
    

    That would cause that section to be visible only when Discount is not zero.