?
Solved

Crystal report question - running total?  Variable?

Posted on 2007-04-06
7
Medium Priority
?
352 Views
Last Modified: 2010-05-18
Crystal Report 8.5.  I need a report that shows sales data based on customer join date and purchase activity.  Let's say there are 2 tables one containing contact info and the other purchase history joined by contact_id.  I need to show the count of contacts who made purchases within the first year of them becoming a customer, second year, third year etc.  I tried using a running total using and evaluate using a formula that with a datediff calculation and the numbers does not look right.  
0
Comment
Question by:nkuo
  • 4
  • 3
7 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 18864616
Are you looking for the first purchase or do you need all purchases accounted for?
By that i mean if i signed up in July 2004.  Purchases in Oct 2004, Aug 2005, and Dec 2006  
Do you count
   1st year - 1  
   2nd year - 1
   3rd year -1

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 18864618
Can you show how you are counting and the results along with sample data?

mlmcc
0
 

Author Comment

by:nkuo
ID: 18865126
only first purchase.  
Sample data would be something like below
contact table
contact_id      Join_date
1      1/1/2004
2      12/23/2005
3      2/29/2007
4      4/2/2006

Order table
order_id      order_date      order_contact_id
1      6/23/2006      1
2      1/21/2007      1
3      12/1/2006      2
4      2/29/2007      3
5      4/5/2006      4

I created an 'purchased within one year'  distinct count running total evaluating
DateDiff ("d", {Contact.Join_Date},Minimum ({Order.Order_Date}, {Contact.Contact_Id}) )  < 365  
would this work?  What is the best way to create the report I want?


0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 

Author Comment

by:nkuo
ID: 18865162
report can look something like

      Less than 1year      2 years      after_2year
Total      2                           1       1            
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 18865598
Try this idea

In the report header add a formula
Add a fromula
Name - DeclVars
WhilePrintingRecords;
Global NumberVar Less1Year := 0;
Global NumberVar TwoYear := 0;
Global NumberVar After2Year := 0;

Add a group to the report - group on Contact_ID
Sort the report on SALE DATE

Add a formula to the group header
Name - WaitTime
WhilePrintingRecords;
Global NumberVar Less1Year;
Global NumberVar TwoYear;
Global NumberVar After2Year;
Local NumberVar WaitTime;

WaitTime := Datediff("yyyy",{qry_contact_orders.Join_Date},{qry_contact_orders.order_date});

if WaitTime = 0 then
   Less1Year := Less1Year + 1
else if WaitTime = 1 then
    TwoYear := TwoYear + 1
else
    After2Year := After2Year + 1;
""

Add formulas to the report footer
Name - Disp1Year
WhilePrintingRecords;
Global NumberVar Less1Year;
Less1Year

Name - Disp2Year
WhilePrintingRecords;
Global NumberVar TwoYear;
TwoYear

Name - DispAfter2Year
WhilePrintingRecords;
Global NumberVar After2Year;
After2Year

You can add text or labels as necessary

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 18867237
Glad i could help

mlmcc
0
 

Author Comment

by:nkuo
ID: 18867266
Mlmcc. Thank you very much for your help.  
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question