Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Data Connectivity
Message Icon Topic: calculation Post Reply Post New Topic
Page  of 2 Next >>
Author Message
kader
Newbie
Newbie
Avatar

Joined: 11 Jun 2012
Location: Qatar
Online Status: Offline
Posts: 18
Quote kader Replybullet Topic: calculation
    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 ?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet 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
IP IP Logged
kader
Newbie
Newbie
Avatar

Joined: 11 Jun 2012
Location: Qatar
Online Status: Offline
Posts: 18
Quote kader Replybullet 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.
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet 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({@Type1})
 
Regards,
Ryan.
IP IP Logged
kader
Newbie
Newbie
Avatar

Joined: 11 Jun 2012
Location: Qatar
Online Status: Offline
Posts: 18
Quote kader Replybullet 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
 
 
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet 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({@type2})*1.15)/sum({@type1}))+1
 
Result
if {table.type} = 1 then {table.price} * {@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.


Edited by rkrowland - 13 Jun 2012 at 3:56am
IP IP Logged
kader
Newbie
Newbie
Avatar

Joined: 11 Jun 2012
Location: Qatar
Online Status: Offline
Posts: 18
Quote kader Replybullet 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
 
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet 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
 
This ofcourse assuming you only want to count the modifier against type1 records.
 
Regards,
Ryan.
IP IP Logged
kader
Newbie
Newbie
Avatar

Joined: 11 Jun 2012
Location: Qatar
Online Status: Offline
Posts: 18
Quote kader Replybullet 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 ?
IP IP Logged
kader
Newbie
Newbie
Avatar

Joined: 11 Jun 2012
Location: Qatar
Online Status: Offline
Posts: 18
Quote kader Replybullet 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 ??
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.017 seconds.