Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Is running total the best solution? Post Reply Post New Topic
Page  of 2 Next >>
Author Message
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Topic: Is running total the best solution?
    Posted: 31 Jul 2012 at 2:54am
Hello,
 
Im stuck!! hope someone can help.
 
This is what i need to achieve;
 
We have customers who purchase 2 different products (product A & product B).
We are running a points promotion on these 2 products for July / Aug / Sept/
 
If a customer purchases Product A, they get 1 point. if they purchase product B, they get 2 points.
 
Thats easy enough.
 
Simply;
 
GROUP 1 =     CUSTOMER /JULY TOTAL /JULY  PRD A /JULY PRD B/POINTS A/POINTS B/TOTAL POINTS
 
Lets say the customers July total was 95 units, with 35 units being prdt A and 60 units being prdt B. 
 
his points would be 35+120 = total points 155.
 
 
 
The hard part;
 Management want points accumulated ONLY on unit sales ABOVE the customer average monthly sales from Jan > Jun.
 
So if the customers average was 50 units per month for the first 6 months, then he would only accumulate points on 45 units.  (July's 95 units  - avg 50 units)
 
My problem now is, how do I know how many points to allocate to the 45 units over the average threshold?

I need to identify, exactly WHEN they exceed the 50 units average, then look at the remaining 45 unit purchases, and give 1 or 2 points based on whether its a product A or a product B.

 
I have tried;
 
GROUP 1 =     CUSTOMER /JULY TOTAL /JULY  PRD A /JULY PRD B
 
Then in DETAILS, have the INVOICE DATE, with the UNIT Quantity, and a Running Total.
I get/understand this bit, and I can see when the RT exceeds 50 units.
 
GH1 =         CUSTOMER A / JULY=95 / PRD A=35 / PRD B=60
 
Details =     01/07/2012     PRD A        5 unit       RT = 5           
                   03/07/2012     PRD B        7 unit       RT = 12
                   05/07/2012     PRD A      10 unit       RT = 22
                   09/07/2012     PRD B        4 unit       RT = 26
                   12/07/2012     PRD B        4 unit       RT = 30
                   12/07/2012     PRD B      19 unit       RT = 49
                   14/07/2012     PRD B        1 unit       RT = 50    <<< HERE
                   14/07/2012     PRD B      15 unit       RT = 65
                   17/07/2012     PRD A      10 unit       RT = 75
                   18/07/2012     PRD A      10 unit       RT = 85    
                   22/07/2012     PRD B        6 unit       RT = 91    
                   24/07/2012     PRD B        4 unit       RT = 95           


I then wrote another formula like;  (which I was hoping to sum by customer and *2)
 
IF {#rtotal0}>= 50 AND {@prductCHECK}="B" THEN {TRANSACTIONS.QTY}
 
BUT, I cannot then summarize this formula by customer as I am using a summarized field {RT} in the formula.
 
 
:|
 
Can anyone provide some assistance? or an easier method to achieve what i want to achieve?
 
Thanks for your help.
 
Mike.
 


 


Edited by Robotacha - 31 Jul 2012 at 6:01am
Regards,

Michael Jones
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 31 Jul 2012 at 3:21am
well...the simple answer is don't summarize using an aggregate function.  Use shared variables / running totals and create your own summaries.
 
Yes more work, but it is the way around these situations.
 
HTH
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 31 Jul 2012 at 3:31am
hello,

Yes, it helps slightly. I thought thats the route I would need to go down, but honestly, Im a right novice with shared variables, so im sort of in the same situation. I dont know where to start or even know what to 'share'
 
what field / value would I declare as a shared variable? Can you sum shared variables?
 
Do you know of any threads i could look at for reference?
Regards,

Michael Jones
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 31 Jul 2012 at 3:32am
What would you do in my situation?
Regards,

Michael Jones
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 31 Jul 2012 at 4:13am
there are lots of threads with shared variables...i've written quite a few.
here's the summary: shared variables typically come in groups of 3, increment, display, reset.
 
reset, typically in a group header
shared numbervar x;
x := 0;
""  // will hide the zero on your report
 
display, typically in a group footer
shared numbervar x;
x
 
increment, typically in the detail section
shared numbervar x;
 
if {table.field} = something then
  x := x + {table.field1}
else
  x := x + {table.field2};
 
"" //again hides the value of x on the report
 
= is used to test for values being equal
:= is used to assign a value to a variable.
 
the increment uses an 'if' as i am assuming that you want to control what values are used.  The if part can be as simple or as complex as you want and doesn't need the else...it's all up to you and how/what the report requirements are.
 
HTH...some more
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 31 Jul 2012 at 4:19am
Yes, it certainly does help... some more :D

i will give it a go now and report my results soon !

thankyou very much for your help.
 
Regards,

Michael Jones
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 31 Jul 2012 at 5:39am
I really dont know what Im doing.
 
I think im going to give up on this one :(
 
Cant seem to get the results I want. Cant work out the logic for it :(

This is what I have and what I want to achieve:

http://img152.imageshack.us/img152/5163/93035810.jpg


Edited by Robotacha - 31 Jul 2012 at 6:00am
Regards,

Michael Jones
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 31 Jul 2012 at 6:51am
so why not a formula to display the running total, like:
 
if runningTotal < 50 then
 0
else
 runningTotal - 50
 
i don't use running totals, so I am not sure of the syntax, but that would be the idea.
IP IP Logged
Robotacha
Groupie
Groupie
Avatar

Joined: 11 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 97
Quote Robotacha Replybullet Posted: 01 Aug 2012 at 3:29am
I tried that, but it dotn work.
Regards,

Michael Jones
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Aug 2012 at 4:22am
this is not my area of expertise at all but try running two values in the same shared variable. one is for your actual sum to determine the threshold (x), the other is your dispaly value (y)
 
group header set value
shared numbervar x;
shared numbervar y;
x := 0;
y := 0;
 
summary formula for details calculation
shared numbervar x;
shared numbervar y;
x := x + {TRANSACTIONS.QTY};
y := y + (if x >50 then {TRANSACTIONS.QTY} else 0);
 
display formula for footer
shared numbervar y;
 
 


Edited by DBlank - 01 Aug 2012 at 4:22am
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.031 seconds.