Question: **crystal reports formula field**
Good day,
I am making a sales report on Crystal Report - VS2010 c#

I have this view in MS SQL

vSales

```
OrderNo

OrderDate

Amount

PaymentType

```

Payment type can either be Cash or Check
I performed select all because I need both in the same report

so how do I get the sum of Amount where PaymentType is equal to cash?

I used Sum for my total Amount, both check and cash, in the formula workshop

```
Sum ({vDailySales.Amount})

```

I can't modify my SELECT statement because I need all the record with cash & check payment

Answer: 
Create two formulas - CashAmount and CheckAmount, for example second one:

```
if {vDailySales.PaymentType}="cheque" 
then {vDailySales.Amount}
else 0

```

On report, use aggregates of said formulas - like Sum({@CashAmount}).
A third option is to use a running-total field. Because of how they are calculated, they need to be in a footer section.

To create one, follow these steps:

1. select the {vDailySales.Amount} field on the canvas, right click, then select Insert, Running Total...
2. Set the Running Total Name field as appropriate, perhaps 'Sum of Cash'.
3. Ensure that the Type of Summary is 'sum'.
4. Select the 'Use a formula' option, click the conditional-formula button, then enter the following as the formula's text:
{vDailySales.PaymentType}="Cash"
5. Select 'Never' for the Reset option or 'On change of group' (selecting the appropriate group) if this RT field will tally an amount by group.
6. Place field in the Report Footer section.

Repeat the process for a second running-total field that will summarize cheques (change step 4 to reference "Cheque" instead of "Cash".