Solved

How do I create multiple subreports to link to 1 main report by different dates and totals

Posted on 2011-09-14
23
280 Views
Last Modified: 2012-05-12
I need to create a crystal report which will show different categories, and then a total of revenue for these catogories and then a seperate subsection of Cost of Goods

The Main report should look something like this

Number    Name      Current Month   YTD    Last YR Month    Last YR YTD
    1              a               1,000            12,000      988                  10,222
    2              b               2,000            15,000      1200                19000
    3              c                680               4000         500                  2800

Just an example..It would be good to probably prompt for at least the Month they want to see, everything else can feed off of that as far as formulas.
0
Comment
Question by:Jennifer Barman
  • 14
  • 6
  • 3
23 Comments
 

Author Comment

by:Jennifer Barman
ID: 36539209
I forgot to add a total for each of these at the last line...
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36539325
Why do you need a subreport?

mlmcc
0
 

Author Comment

by:Jennifer Barman
ID: 36539340
Well I suppose if there is a way to accomplish the above I am all for it..
0
 

Author Comment

by:Jennifer Barman
ID: 36539345
The user will need to be able to put the parameter in ... maybe I am making it more complicated then it needs to be..
0
 

Author Comment

by:Jennifer Barman
ID: 36539377
I guess the issue is that if I have the user limit the parameter to that particular month.. then how do I get the other fields to see past data without using a seperate query-report??
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36539414
Have the user input a date and use it to select records.

{DateField} Between Date(Year({?DateParameter}),1,1) AND {?DateParameter})
OR
{DateField} Between Date(Year({?DateParameter})-1,1,1) AND Date(Year({?DateParameter})-1,Month({?DateParameter}),Day({?DateParameter})))

In the report you can use formulas
CurrentYTD
If Year({DateField}) = Year({?DateParameter}) then
    {AmountField}
Else
    0

CurrentMonth
If Year({DateField}) = Year({?DateParameter}) AND month({DateField}) = Month({?DateParameter})    then
    {AmountField}
Else
    0

Similarly for PastYTD

If Year({DateField}) = Year({?DateParameter})-1  then
    {AmountField}
Else
    0

PastMonth
If Year({DateField}) = Year({?DateParameter})-1 AND month({DateField}) = Month({?DateParameter})    then
    {AmountField}
Else
    0


Use thise formulas to get the totals for the report

mlmcc
0
 

Author Comment

by:Jennifer Barman
ID: 36539438
I will test this theory.. I appreciate your assistance.
0
 

Author Comment

by:Jennifer Barman
ID: 36539611
This does not seem to be working.. maybe I am not understanding it correctly.

I have created an input parameter called DateRange this is in the select expert
Where date is equal to {dateRange} so now the enitre report is "only" pulling that data into the report.. it can't go backwards.. that is why I am pretty sure I need to enter in a subreport.. something not tied to the main data..
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36539800
My formulas assume a single date field for the rnd date of the period then you use the first formula to select records

//This year's records
{DateField} Between Date(Year({?DateParameter}),1,1) AND {?DateParameter})
OR
//Last Year's records
{DateField} Between Date(Year({?DateParameter})-1,1,1) AND Date(Year({?DateParameter})-1,Month({?DateParameter}),Day({?DateParameter})))


If you want to enter a range then
{DateField} In {?DateRange}
OR
{DateField} +365 IN  {?DateRange}

mlmcc
0
 
LVL 34

Expert Comment

by:James0628
ID: 36541786
The basic idea is to "adjust" the date field (or parameter) values so that you can use the same parameter to include the records for last year.  If your daterange parameter actually has a range of dates, you can (as in mlmcc's last formula) add 1 year to the date field and that will include any records from last year that fall in that range.  You could subtract 1 year from the range instead, but adding a year to the field is a little bit simpler.

 FWIW, you might want to give some thought to how you want to handle leap years.  For example, if you use 02/29/2012 as the end of your date range, what should be the cutoff point in 2011 (the prior year)?  02/28, or 03/01?  And if you use 02/28/2013 or 03/01/2013 as the end date, which one of those should include 02/29/2012 in the prior year?

 Also, I have one correction to mlmcc's first formula.  You need to use IN, instead of BETWEEN (unless they've added a BETWEEN operator in some version after CR 10).

 James
0
 

Author Comment

by:Jennifer Barman
ID: 36543489
so in the actual select expert I should be using the parameter something like this???

{Command.RevGLAccountNumber} = "4100" and
{Command.Date} IN Date(Year({?DateRange})-1,1,1) AND Date(Year({?DateRange})-1,Month({?DateRange}),Day({?DateRange}))


I am getting an error .. but I am still working with it.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 100

Expert Comment

by:mlmcc
ID: 36543641
What error are you getting?


That will get last years data.  You need the same to get this years data.  That works if the parameter is a single date.

{Command.RevGLAccountNumber} = "4100"
and
(
{Command.Date} IN Date(Year({?DateRange})-1,1,1) AND Date(Year({?DateRange})-1,Month({?DateRange}),Day({?DateRange}))
OR
{Command.Date} IN Date(Year({?DateRange}),1,1) AND Date(Year({?DateRange}),Month({?DateRange}),Day({?DateRange}))
)

mlmcc
0
 

Author Comment

by:Jennifer Barman
ID: 36543743
I have added it to my select expert just as you wrote above..
{Command.RevGLAccountNumber} = "4100"
and
(
{Command.Date} IN Date(Year({?DateRange})-1,1,1) AND Date(Year({?DateRange})-1,Month({?DateRange}),Day({?DateRange}))
OR
{Command.Date} IN Date(Year({?DateRange}),1,1) AND Date(Year({?DateRange}),Month({?DateRange}),Day({?DateRange}))
)


I have the parameter set as follows see image. crystal issue crystal issue2
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 36543999
Sorry we both got it wrong
It should be
{Command.RevGLAccountNumber} = "4100"
and
(
{Command.Date} IN Date(Year({?DateRange})-1,1,1) TO  Date(Year({?DateRange})-1,Month({?DateRange}),Day({?DateRange}))
OR
{Command.Date} IN Date(Year({?DateRange}),1,1) TO  Date(Year({?DateRange}),Month({?DateRange}),Day({?DateRange}))
)

mlmcc
0
 

Author Comment

by:Jennifer Barman
ID: 36544072
Okay.. so I think I got the data in now.. thats great.. now i need to get my columns to show the right data..

Now I have these totals grouped using the running total fields.. can I still use the first response for breaking these numbers up?
0
 

Author Comment

by:Jennifer Barman
ID: 36544113
The totals are not working out right.. I am starting with just the current month.
0
 

Author Comment

by:Jennifer Barman
ID: 36544200
If Year({Command.Date}) = Year({?DateRange}) AND month({Command.Date}) = Month({?DateRange})    then
   {Command.Amount}
Else
    0

I need to get the full date.. like Aug 1 2011 thru Aug 31 2011.. I think it is only returning the exact date!!.. 8/1/2011..
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36544352
WHat are you entering as the date?

The filter will return all data through the date you enter.  If you want 1 Jan - 31 Aug then enter 31 Aug as the date.

mlmcc
0
 

Author Comment

by:Jennifer Barman
ID: 36544398
ahh got it!! :)
0
 

Author Closing Comment

by:Jennifer Barman
ID: 36544405
Very helpful .. stuck with me to the end! :)
0
 
LVL 34

Expert Comment

by:James0628
ID: 36548017
About that error: I noticed the BETWEEN.  Didn't notice the AND.  :-)  Makes sense that it would be there.  I just didn't look that carefully.

 James
0
 

Author Comment

by:Jennifer Barman
ID: 36548993
Thanks James! :)
0
 
LVL 34

Expert Comment

by:James0628
ID: 36553703
No problem.  Also, as I mentioned earlier, you might want to give some thought to leap years (if you haven't already) and decide if you want to handle those in a specific way.

 James
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now