Skip to Content
0

Crystal calculation

Apr 12 at 11:14 AM

21

avatar image

Hi,

I got a requirement, i would like to calculate in Crystal report 2016 following formula.But I am unable to write the syntax/formula for this.

% Qty = ( Total of Avialble Qty / total of target qty ) * 100

Kindly help me out, thanks in advance guru.

Regards,

Bharathi


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Dell Stinnett-Christy Apr 12 at 02:30 PM
0

Is this for a single record or for a set of records? If it's for a single record, you'll do something like this:

If {MyTable.TargetQty} <> 0 then {MyTable.AvailableQty} % {MyTable.TargetQty} else 0

There are a couple of things to note about this:

- The initial check for target qty > 0 prevents a divide by 0 error
- The "%" operator automatically does the divide then multiply by 100 to calculate a percentage.

If this is for a set of records, you'll use the "sum()" function. If you're looking for a grand total, you'll just pass the field to the function - sum({MyTable.MyField}). If you're looking for a subtotal based on a group in your report, you'll need to add the group field (which MUST match a group in your report!) - sum({MyTable.MyField}, {MyTable.GroupField}). So, your formula will look something like this:

If sum({MyTable.TargetQty}, {MyTable.GroupField}) > 0 then sum({MyTable.AvailableQty}, {MyTable.GroupField}) % sum({MyTable.TargetQty}, {MyTable.GroupField}) else 0

-Dell

Share
10 |10000 characters needed characters left characters exceeded