Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: summarizing a variable Post Reply Post New Topic
Author Message
kreusch
Newbie
Newbie


Joined: 04 Nov 2011
Online Status: Offline
Posts: 22
Quote kreusch Replybullet Topic: summarizing a variable
     Posted: 30 Dec 2013 at 9:24am
Is there a way to get a summary for a variable?

I am creating a report that I use summaries to get totals for various groups. I was unable to summarize a formula (error read "field cannot be summarized" I am assuming b/c it contains summaries)
So I created a variable which I thought would help me get around that problem, however I still cant summarize it.

Any suggestions?

Thanks
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 31 Dec 2013 at 4:18am
can you give a little more detail on what it is that you are totaling and how it's laid out?

if you are initializing your variable in the header, building it in the details and showing it in the footer you don't really need to summarize it since it will be summed in the footer. that is, if you do it like this.

header -
shared numbervar var1;

details -
shared numbervar var1 : = 0;
var1 = var1 + (whatever formula you are using)

footer
shared numbervar var1;

var1
IP IP Logged
kreusch
Newbie
Newbie


Joined: 04 Nov 2011
Online Status: Offline
Posts: 22
Quote kreusch Replybullet Posted: 31 Dec 2013 at 8:31am
I am making an income statement in which I take the current months GL totals and break them down by GL account type (revenue, expense, etc) I also am required to show percent of revenue for each gl account and a percentage of revenue total for each gl account type.
So I have 2 groups,
GL account type,
Gl account number

I use formulas to get the totals for the GL account types by putting them in the detail section, suppressing that sections and then summarizing them by group.

everything works fine expect that I cant get the summary for the percentage of revenue (b/c I want to sum a field that already uses summation)

SO I created a variable:

Global NumberVar TotalRevenue;

TotalRevenue:=If {GLIncomeStatementStage1.GLAccountType}= "Net Sales" then
Sum ({@Current Period Credit}, {GLIncomeStatementStage1.GLAccountType})-Sum ({@Current Period Debit}, {GLIncomeStatementStage1.GLAccountType})


then I created a variable for GL account total

Global NumberVar TotalGLAccount;
TotalGLAccount:=


If {GLIncomeStatementStage1.GLAccountType}= "Net Sales" then
Sum ({@Current Period Credit}, {GLIncomeStatementStage1.GLAccountNumber})-Sum ({@Current Period Debit}, {GLIncomeStatementStage1.GLAccountNumber})
else Sum ({@Current Period Debit}, {GLIncomeStatementStage1.GLAccountNumber})- Sum ({@Current Period Credit}, {GLIncomeStatementStage1.GLAccountNumber})

then I created a variable to do the math for each GL account percentage of revenue:

WhilePrintingRecords;
Global NumberVar TotalRevenue;
Global NumberVar TotalGLAccount;
Global NumberVar PercentageRevenue;

PercentageRevenue:= if TotalRevenue = 0 then 0 else ( TotalGLAccount/TotalRevenue)*100


Now I need a total for that variable, PercentageRevenue in the report footer, GL account type

I hope this help, sorry it is so long. Maybe I am thinking about this from the wrong angle???
IP IP Logged
kreusch
Newbie
Newbie


Joined: 04 Nov 2011
Online Status: Offline
Posts: 22
Quote kreusch Replybullet Posted: 31 Dec 2013 at 9:08am
I figured it out....
sometimes just typing it all out makes it make sense

Thanks for your help
IP IP Logged
drintharamy
Newbie
Newbie
Avatar

Joined: 21 Jun 2013
Location: United States
Online Status: Offline
Posts: 8
Quote drintharamy Replybullet Posted: 06 Jan 2014 at 4:41am
Can you share you solution with your original issue?
 
I am actually doing something very similar to what you're doing.  I want to summarize my calculated formula in my footer but I am getting the same error message you got.
 
Thanks!
DOUANG RINTHARAMY
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