Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Calculate from SUM Post Reply Post New Topic
Author Message
Minco
Groupie
Groupie
Avatar

Joined: 28 Nov 2012
Location: United States
Online Status: Offline
Posts: 62
Quote Minco Replybullet Topic: Calculate from SUM
    Posted: 14 Mar 2016 at 11:15am
I have a table consisting of YEAR, MONTH, DOLLAR, and 2 different CATEGORY.

2014 1   $330.40    $742.61

This would represent the Category sales for Jan of 2014... call them category A and category B. The data is sorted by year and month, then grouped by Year and a SUM of the columns are at the group's Footer.

The issue is, I also need to calculate the growth year after year so I need to calculate Jan 2015 minus the sales of Jan 2014 to figure out the difference. I can't use the footer SUM to do this or I'm just subtracting it from itself.

Any suggestions on an easy fix?
Thank you in advance!
Be kind to those less fortunate.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Mar 2016 at 4:46am
one way, you can use running totals with evaluation formula to create two distinct sums that can be used in a report footer
IP IP Logged
Minco
Groupie
Groupie
Avatar

Joined: 28 Nov 2012
Location: United States
Online Status: Offline
Posts: 62
Quote Minco Replybullet Posted: 15 Mar 2016 at 4:59am
Clarification? How do I create a formula that takes the group sum and subtracts it from the same group in the prior year?

Thank you!
Be kind to those less fortunate.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Mar 2016 at 5:24am
create two running totals
each with an evaluation formula
rest as never
RT1 use table.year = year(today)
RT2 use table.year = year(today)-1

#RT1-#RT2
must be placed in the report footer

Edited by DBlank - 15 Mar 2016 at 5:25am
IP IP Logged
Minco
Groupie
Groupie
Avatar

Joined: 28 Nov 2012
Location: United States
Online Status: Offline
Posts: 62
Quote Minco Replybullet Posted: 15 Mar 2016 at 5:49am
This is getting very close... I like it so far. I understand and got the sales for the Year as suggested. However, I need to compare the month of January 2015 to the month of January 2014.... And then the month of January 2016 to the month of January 2015.

Would I have to create a running total for each month in each year?

Thank you again!
Be kind to those less fortunate.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Mar 2016 at 8:16am
that is one possibility.
Another approach is to create one formula field to set a negative value for last year's data and a positive value for this years data and then just sum that. you could also use a CrossTab set (grouped) to the month value and sum it per month to show the difference on each month as well as the total for the year.

if table.year = year(today)-1 then table.dollars *(-1) else table.dollars

Edited by DBlank - 15 Mar 2016 at 8:19am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Mar 2016 at 8:17am
also this second approach allows you to place summaries and crosstabs in the report header (unlike the running totals)
IP IP Logged
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.014 seconds.