Print Page | Close Window

Formula Field Problem

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2188
Printed Date: 28 Apr 2024 at 1:14am


Topic: Formula Field Problem
Posted By: mian_ghous
Subject: Formula Field Problem
Date Posted: 31 Jan 2008 at 6:32am
hi there
 
i have three columns in ma source tabel
say   TruckQty, AttachmentQty  and  Class nad SOnum "for group"
 
first 2 colmn are int type
and calss is string having 2 values only say class1 and class2
 
now i want sum of att+model for class1 and same for class2
,,,i have used this in a formula field
 
if {Details.CLASS}="Class 1"
then
Sum ({Details.AttachmentQty}) +Sum({Details.TruckQty})
 
same for 2nd formula field for class 2
 
but problem is that on completing the report
it only populate formula field accoring to the last record class
.......mean ma last record has class 1
so it will sum these for class 1 and leaving 2nd formula filed to 0 ,although it has records for class 1 and class 2 both....
so please tell
 
 
 



Replies:
Posted By: Lugh
Date Posted: 31 Jan 2008 at 8:14am
This is a classic problem.  Take another look at the logic of your statement:

If (the Class of the current record is "Class 1")
Then
(take the sum of all AttachmentQty)
added to
(take the sum of all TruckQty)

This is, clearly, not what you want.

Instead, create a pair of formulas for each record (i.e., put in the details section).  Each formula should look like:

If {Details.CLASS} = "Class 1" //or "Class 2" in the second formula
Then {Details.AttachmentQty} + {Details.TruckQty}

Then, take the Sum of each of these formulas.




Posted By: mian_ghous
Date Posted: 14 Feb 2008 at 10:01pm
thanks :)


Posted By: mian_ghous
Date Posted: 15 Feb 2008 at 4:48am

dear is it possible to assign default value to formula field...

like in our previous case some time sum is 0 but formula field does not show any thing,,,i want it to show 0;;
 
so please tell me how to do this



Print Page | Close Window