Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Cross Tab Formula Post Reply Post New Topic
Author Message
Me_Evans
Newbie
Newbie


Joined: 03 May 2010
Location: United States
Online Status: Offline
Posts: 10
Quote Me_Evans Replybullet Topic: Cross Tab Formula
     Posted: 05 May 2010 at 4:08am
I am running Crystal Reports XI with a cross tab with the following data.
 
I have one row with ledger.amount and another row with ledger.adjust.  I want to be able show the difference between the two values.
 
How do I go about this?
 
 
Michelle
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 05 May 2010 at 12:17pm

What fields are in your table in addition to the ledger.amount and ledger.adjust fields?  What field(s) are the rows in your Cross-tab based on?

-Dell
IP IP Logged
Me_Evans
Newbie
Newbie


Joined: 03 May 2010
Location: United States
Online Status: Offline
Posts: 10
Quote Me_Evans Replybullet Posted: 06 May 2010 at 8:04am
The cross table rows are based on Ledger.Category.
 
I have several categories that I am summarizing and then I need the difference between the two totals. 
 
Any help would be greatly appreciated.
 
Michelle


Edited by Me_Evans - 06 May 2010 at 8:06am
Michelle
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 May 2010 at 8:19am
Not knowing what your data looks like I'm going to assume something fairly simple will work for you.
 
Try creating a formula that is something like this:
 
{ledger.amount} - {ledger.adjust}
 
If either field can be null, you'll have to do something like this:
//Set up the variables and their default values
NumberVar amount := 0;
NumberVar adjust := 0;
//Set the values of the variables if the fields are not null
if not IsNull({ledger.amount}) then amount := {ledger.amount};
if not IsNull({ledger.adjust}) then adjust := {ledger.adjust};
//Set the final value
amount - adjust
 
Now sum that formula in your crosstab.  This should get you the total difference between the two.
 
-Dell
IP IP Logged
Me_Evans
Newbie
Newbie


Joined: 03 May 2010
Location: United States
Online Status: Offline
Posts: 10
Quote Me_Evans Replybullet Posted: 06 May 2010 at 8:46am
That works great.  I was reading too much into this.  I have just started working with cross tabs.
Another question:  I am using the same data as before, but I have several rows using Group Options (example group a, b, c, and d) and another group using (group e, f, g, and e), I want to be able to have a sub total for each group and a total at the end.  These rows are listed with a and then another row with b and so on.
Any thoughts on this one.  Currently, I have them set up as separate cross tabs.  There has to be a better way.
Michelle
Michelle
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 May 2010 at 9:12am
Create a formula that will group together your groups as you need to.  We do this to group together our clients by type and it looks something like this:
if {client.name} = 'Client A' or {client.name} = 'Client B' then 'Group A'
else if {client.name = 'Client C' or {client.name} = 'Client D' then 'Group B'
else 'Group C'
Use this formula as the outer group in your crosstab and you'll be able to get the subtotals like I think you want them.
 
-Dell
IP IP Logged
Me_Evans
Newbie
Newbie


Joined: 03 May 2010
Location: United States
Online Status: Offline
Posts: 10
Quote Me_Evans Replybullet Posted: 06 May 2010 at 10:02am
I will try this.  Thanks
Michelle
IP IP Logged
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