Print Page | Close Window

Subreport Preview

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21434
Printed Date: 02 May 2024 at 7:49pm


Topic: Subreport Preview
Posted By: Dr4ke
Subject: Subreport Preview
Date Posted: 15 Apr 2015 at 11:18pm
Morning all,

I currently have a report setup which displays the Month-To-Date figures in a Calendar view, which works perfectly well on the main report.

Each 'day' of the calendar basically shows a number (which is a count of the number of entries for each day). I can then double click the number which takes me to the subreport.... but not in the way I expect.

I thought this would be considered a 'drill down' but instead it opens a 'Preview' tab. I was aiming to use the 'detail' section to show all of the entries once the user drill down into the Subreport but can't if it's in Preview...

Is there a way to suppress based on whether it's a preview or not? Or force it to drill down rather than preview?



Replies:
Posted By: DBlank
Date Posted: 16 Apr 2015 at 3:59am
Do you mean that the 'day number' for each 'calendar day' is actually a subreport displaying some sort of summarized data in the main report?


Posted By: Dr4ke
Date Posted: 16 Apr 2015 at 5:40am
There is a subreport for each 'day' in the sense that all 'Sundays' are one subreport, all 'Mondays' are one subreport etc etc. 


Posted By: DBlank
Date Posted: 16 Apr 2015 at 6:06am

and when you click on that WeekDay number it is actually clicking on the sub report that is displaying a value from the Sub Report, which in turn opens the subreport but in the summarized way and not showing the details.

First, is there a reason you are using subreports (I assume 7 - one per weekday) rather than bring all the dat ainto the main report and drilling into as you desired?
 
You also may be able to do what you want by running an on demand sub report attached to an object that overlays your other subreport. It would esentially be a copy of the existing subreport with the same links but be in "detail view" (no suppression) when it opens. I have not tried ot the overlapping process but have added on-demand sub reports as links onto other objects with success as a way of mimicking a user experience of drill down.


Posted By: Dr4ke
Date Posted: 16 Apr 2015 at 11:28pm
Yes that's right. It has a link between the subreport and main report (using various Parameters and Formulas) and then when I double click the Calendar entry it takes me to the Subreport (which is actually the Subreport Preview instead of actually opening it, which is the problem).

To get it in the display of a Calendar, I don't think it's possible to do it without subreports (yes there is 7 subreports). Doing this all from the main report would result in a list of something similar....

On demand subreports are also unfortunately not feasible as I wouldn't be able to conditionally format the subreport backgrounds (Red, Amber, Green) dependent on the number of entries...

I was hoping there would be an option somewhere where I can turn off the Subreport Preview and make it drill down when double clicked. Even when I'm in the preview mode I can't seem to drill down.....


Posted By: DBlank
Date Posted: 17 Apr 2015 at 11:28am
I should have been clearer that I do not believe there is a way to force a sub-report to move change its drilldowngrouplevel when you launch it as a seperate tab from the main report. THis is why I was giving alternative solutions to make it appear as if that what was happening as I am guessing your end user(s) does not really care about the technical aspect, just how it interacts for them.
if you don't have other things in the main report you can get your 7 'columns' without subreports.
If you want to keep your same existing sub-report process going, did you try using a 'second' on demand sub report as your 'drill down' function?


Posted By: Dr4ke
Date Posted: 19 Apr 2015 at 10:55pm
Thanks again for responding :-)

Oh right, sorry, I obviously misunderstood! That's absolutely correct; they are not bothered about the technicalities beneath the surface... I am intrigued; how would I be able to get the same effect without Subreports?


Posted By: DBlank
Date Posted: 20 Apr 2015 at 4:50am
Do you have to use 'squares' with numbers in them (I assume to mimic the
look of a calendar)?
If you can use a chart you could do grouping on the weekday and drill straight into the data from say the bar in the chart.
If you have to use the boxes you could do that. Just don't want to explore it if it is not necesary.


Posted By: Dr4ke
Date Posted: 20 Apr 2015 at 4:53am
In an ideal world they would be 'squares' with each 'column' representing a different week day. Unfortunately I don't think a chart would suffice for the End Users.


Posted By: DBlank
Date Posted: 20 Apr 2015 at 5:28am
Bring all your data into the main report
Create 7 formula
//Sunday
if weeekday(table.datefield)=1 then 1 else 0
//Monday
if weekday(table.datefield)=2 then 1 else 0
//Tuesday
if weekday(table.datefield)=3 then 1 else 0
etc.
 
Place your 7 boxes in the report header
Add a new sub report
Name =Sunday (or whatever)
set it to an 'On demand subreport (similar to a hyperlink)'
Add you links
Shrink the size of this sub report width to fit inside the sunday box and place it inside your 'sunday box'.
right click on it and select 'format sub report'
select subreport tab
click on the formula field 'on-demand subreport caption'
add a formula here
Totext(SUM( mailto:%7b@Sunday%7d%29,0 - {@Sunday}),0 )
 
Click OK
Your hyper link (in the main report) should now be the Sunday count from the main report
You can now design the sub report to look anyway you want.
Repeat for the other days.
I would get sunday exactly like you want it then just make copies of it for the other days. It would only be making changes to the select or links.
 
This is one approach.
 
 


Posted By: Dr4ke
Date Posted: 20 Apr 2015 at 6:10am
Thank you :-) I'll have a play around with this and let you know!


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 12:20am
Hey!

I have this working but unfortunately it only shows one 'Sunday' box for the month. Is it possible to have one box/count per 'Sunday'? I.e., for April, it would show 4 Sundays; 5, 12, 19, 26 and ideally it would show those numbers in the box also...

Thanks in advance :)


Posted By: DBlank
Date Posted: 21 Apr 2015 at 1:54am
so you are doing a full month calendar?
I assume you are allwoing a user to choose the month or it is dynamic in some fashion?
Is the number shown a total for a specific day of the month?
When a user clicks on the calendar are they drilling into that calendar day?
 
Can you write a stored proc as your data source?


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 1:59am
Yes that's right, sorry I obviously didn't explain that properly!

It is dynamic in the sense that it is 'the current month' showing a Month-To-Date figure.

Yes it's a total for a specific day in the month.

That is the plan; they click on one of the 'days' and they see all the entries for that day.

I've never figured stored proc's out to be honest...?


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 2:11am
Sorry I've just done some research and Stored Proc's are not what I thought they were (I was thinking of SQL Expressions).

I've never looked at Stored Proc's.... Help :-)


Posted By: DBlank
Date Posted: 21 Apr 2015 at 2:15am
thinking about this
i think the real issue is that your looking at a full month of data and the first of each month may be any weekday. Therefore your sums, which would be based on day of the month need to slide between boxes and then roll up from there.
Correct?


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 2:17am
Yes, if I've understood correctly, that is right


Posted By: DBlank
Date Posted: 21 Apr 2015 at 3:05am
I think this might work
you will need to group by the week of the year so add a formula field to get that value
//weekofyear
datepart("ww",table.datefield)
group on this formula field
move your week day boxes into the group header
change your summary displays to use the group condition in the sum
each of your seven sub reports will need to alter the link to pass the group value (of the week of the year, the date range and the weekday)
get your month calendar set first and alter your months to make sure this is dynamically doing what you need it to for any of the months.
 


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 5:00am
I'll give this a go :-) thank you!


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 6:08am
Any chance you could help me out a little with the subreport links? So I have created one box with a Subreport (Sunday) and grouped on the Weeknumber... I have four boxes (result!).

I now know I need to parse something into the Subreport so that it only displays what the group number is.... I've got myself a little muddled and can't quite figure it out.


Posted By: DBlank
Date Posted: 21 Apr 2015 at 6:13am
how are you limiting the data to the one mont in the main report?
parameter? lastfullmonth?


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 6:15am
Currently 'MonthtoDate' - I've made it a little easier on myself at the moment by applying the same condition to the subreport (so I don't have to worry about passing that through, yet)


Posted By: DBlank
Date Posted: 21 Apr 2015 at 6:22am
in the subreport create a formula to get the year week value (same as in your main report for the grouping)
//sr_weekofyear
datepart('ww',table.datefield)
in the main right click on the subreport and select links
select the @weekofyear field form the main report and link it to the @sr_weekofyear from the subreport
 
In the subreport this will appear as a part of the select statement
your overall select statement will be identical for all 7 subreports except that you will change which weekday value to limit
 


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 10:37pm
Thank you :-)

The 'SUM' display numbers now look a lot better but, strangely, aren't completely accurate... Taking the current month (as MTD) we have 4 Sundays:

Week 14 - Hyperlink Display: 0 - Subreport records: 0

Week 15 - Hyperlink Display: 292 - Subreport records: 276

Week 16 - Hyperlink Display: 52 - Subreport records: 49

Week 17 - Hyperlink Display 48 - Subreport records: 45

As you can see they are all out by a bit.... Strange!! I tried using 'Count' instead of 'Sum' but that made the numbers huge (I assume because it was counting the 0's as well as the 1's). I'll keep looking into what's happening...

My next question is if it is possible to have the 'Day' of the month on the boxes as well. For example, for this month, the Sundays would be 05th, 12th, 19th, 26th...?


Posted By: Dr4ke
Date Posted: 21 Apr 2015 at 10:57pm
I've figured out the difference in numbers - because I am using two different tables (one with the date in); because I hadn't included the entries in the report it was counting without limiting....

The only thing left is if I can get the days on the squares then it will be perfect :D


Posted By: DBlank
Date Posted: 22 Apr 2015 at 3:52am
How do you want it displayed?
Just the number of the day of the month or something else?


Posted By: Dr4ke
Date Posted: 22 Apr 2015 at 4:03am
yeah the number is fine - just something to represent the date (not just the day). 


Posted By: DBlank
Date Posted: 22 Apr 2015 at 4:05am

do you ever have days with 0 records?



Posted By: Dr4ke
Date Posted: 22 Apr 2015 at 4:07am
unfortunately, yes. I was going to link the report to an Excel file so I can capture all of the dates, regardless of counts. 


Posted By: DBlank
Date Posted: 22 Apr 2015 at 4:52am
do you have a "calendar table" you can join into the mix?


Posted By: Dr4ke
Date Posted: 22 Apr 2015 at 4:53am
Unfortunately not - I do keep asking about adding one... No such luck so far.


Posted By: DBlank
Date Posted: 22 Apr 2015 at 5:52am
I have to think about this one for a bit.
Do you always have at least one value/row for the entire week?
If not that whole 'row' (or group) would not exist.


Posted By: Dr4ke
Date Posted: 22 Apr 2015 at 5:54am
Again it's not a dead cert that there will be an entry for the entire week - we have had instances where it doesn't....

Another reason I was going to factor in an Excel sheet and 'outer join' it onto the date table/column.


Posted By: DBlank
Date Posted: 23 Apr 2015 at 4:10am
this wiorks if you have data for each day-not sure how to fill in the missing days without a calendar table.
I do not think that Excel will support an outer join as a datasource for (XI)
 
Make 7 formula
//MDforSunday
if datepart("w",table.datefield)=1 then totext(datepart("d",table.field),0)
//MDforMonday
if datepart("w",table.datefield)=2 then totext(datepart("d",table.field),0)
repeat for all 7 days
make group summary for each one as the max value and palce in the correct weekday box at the group header level
 


Posted By: Dr4ke
Date Posted: 24 Apr 2015 at 12:13am
Thank you :-) I will give this a go. 


Posted By: Dr4ke
Date Posted: 05 May 2015 at 12:27am
Hi DBlank, sorry for the delay I was pulled onto a different project. I am still going to look at this and obviously appreciate the help so far! 



Print Page | Close Window