Solved

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

Posted on 2011-09-14
23
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

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 35

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
 
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 35

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 35

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

730 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