Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

crystal reports - formula field conditional statement on what records to sum

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

like image 574
Jacob Pua Avatar asked Jan 18 '23 07:01

Jacob Pua


1 Answers

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}).

like image 70
Arvo Avatar answered Feb 16 '23 09:02

Arvo