Print Page | Close Window

calculation

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16723
Printed Date: 20 Apr 2025 at 10:53pm


Topic: calculation
Posted By: kader
Subject: calculation
Date Posted: 11 Jun 2012 at 11:15pm
How do I get a total of a certain records in the dield to calculate or add to another field ?



Replies:
Posted By: hilfy
Date Posted: 12 Jun 2012 at 4:01am

What are the criteria you're using to determine "certain records"?  Please give us a bit more explanation - there are a couple of ways of doing this, but which one is appropriate is dependent on the requirements.

 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: kader
Date Posted: 12 Jun 2012 at 11:47pm
I have a field call <Total price> and other field is <type> type means it is item type. I am looking the total of <Total price> where type = 1 ( not through grouping.) I need this value to be used to add in another field. Basically I would like to have this total in a variable and this variable could be used in any of the field.


Posted By: rkrowland
Date Posted: 13 Jun 2012 at 12:31am
Create a formula;
 
Type1
if {table.type} = 1 then {table.price} else 0
 
You can then sum this field to give you the total price;
 
Totalprice
sum( mailto:%7b@Type1 - {@Type1 })
 
Regards,
Ryan.


Posted By: kader
Date Posted: 13 Jun 2012 at 3:32am
Item                              Total Price
 
Item type 1                   100
Item type 1                   200
Item type 1                   300
Item type 2                   100
 
Issue is,
 
I wanted to calculate as follows
 
 Item type 2 value (100) add 15% = 115 divided by total of Item type 1 and add  the value of Item type1 to bring in to a different colunm to all lines of where is item type1 exist.
 
(100/100*15+100)/600(total of item type 1)*100(line value)= 19.167+100
Total 119.167
 
 


Posted By: rkrowland
Date Posted: 13 Jun 2012 at 3:53am
Try this (I haven't actually tested this so it might thrown back an error but try it and get back to me)
 
Type1
if {table.type} = 1 then {table.price} else 0
 
Type2
if {table.type} = 2 then {table.price} else 0
 
Modifier
((sum( mailto:%7b@type2 - {@type2 })*1.15)/sum( mailto:%7b@type1%7d%29%29+1 - {@type1}))+1
 
Result
if {table.type} = 1 then {table.price} * mailto:%7b@modifier - {@modifier } else 0
 
Place Type1, Type2 & Result in your details section and modified in the report footer - surpress any that you don't want to be visible.
 
Regards,
Ryan.


Posted By: kader
Date Posted: 13 Jun 2012 at 9:42pm
Thank you very much. It works perfectly  with a small change. How am able to get a grand total of a summary field like <modifier)
 
I cannot click summary icon from the field becouse it is not accessible (summary function)
 
Thanks
 


Posted By: rkrowland
Date Posted: 13 Jun 2012 at 9:58pm
Well if you don't have any groups the modifier here is always going to be the same number - in your example above it will always equal 1.1967 for every record.
 
If you really want a summary of this field you could so something like;
 
Type1Count
if {table.type} = 1 then 1 else 0
 
ModifierTotal
mailto:%7b@modifier - {@modifier } * sum( mailto:%7b@Type1Count - {@Type1Count })
 
This ofcourse assuming you only want to count the modifier against type1 records.
 
Regards,
Ryan.


Posted By: kader
Date Posted: 14 Jun 2012 at 4:25am
Hi, Thank you for support.
 
If you group a field the automatically this field become the first sort. How to avoid this sorting without changing or removing the group ?


Posted By: kader
Date Posted: 14 Jun 2012 at 5:12am
When I am refreshing report giving me an error
 
ODBC error.................. then click the error message another window comes  Error detected by Database DLL
 
How to fix ??


Posted By: kader
Date Posted: 18 Nov 2012 at 9:26pm

can you please give a solution

Field 1                                   Field 2                         Resulf                        200                                        2500.00
200                                        3000.00
200                                       -1000.00                     4500.00
 
 
155                                        1000
155                                       -1000                              0
 
How I can fix a formula in result field ??
 
 
 



Print Page | Close Window