Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Display detail info in Group Header Post Reply Post New Topic
Page  of 2 Next >>
Author Message
mrtj
Newbie
Newbie


Joined: 26 Mar 2013
Online Status: Offline
Posts: 26
Quote mrtj Replybullet Topic: Display detail info in Group Header
    Posted: 17 Apr 2013 at 6:45am
The subject I chose may not be descriptive, so the best I can do to describe my objective is that I want to look across multiple records belonging to an individual and display them all in the group header section.

I have a SQL query (view), that contains a record for lets say each student, his LEVEL in the class, a test number and the date test was taken. Levels are like a promotion that is affixed to a date also.

The Level file:

TomSmith          Level1          01/15/2013
TomSmith          Level2          02/15/2013
TomSmith          Level3          03/15/2013

the test file

TomSmith                   test1     02/01/2013 
TomSmith                   test2     03/01/2013
TomSmith                   test3     04/01/2013


the query view SQL combined file (done in Crystal matched on name)

TomSmith test1 02/01/2013  Level1 01/15/2013
TomSmith test1 02/01/2013  Level2 02/15/2013
TomSmith test1 02/01/2013  Level3 03/15/2013
TomSmith test2 03/01/2013  Level1 01/15/2013
TomSmith test2 03/01/2013  Level2 02/15/2013
TomSmith test2 03/01/2013  Level3 03/15/2013
TomSmith test3 04/01/2013  Level1 01/15/2013
TomSmith test3 04/01/2013  Level2 02/15/2013
TomSmith test3 04/01/2013  Level3 03/15/2013



I  am not allowed (because of missing data and unlimited # of tests, and because I'm not in control of the view nor is anyone willing to take requests to change it)to drop ahead of time these all into 1 record or view with predetermined fields for test1 test2 test3.

So I am displaying
Tom Smith  in Group header
detail a = test1 2/1/13  Level 1 01/15/2013
detail a = test2 3/1/13  Level 2 02/15/2013
detail a=   test3 4/1/13 Level 3 03/15/2013
detail suppress formula eliminates test dates that do not cross chronilogically with level change dates. (the blue ones above are suppressed)

My situation or objective is to print the 3 level promotions(purple ones) next to Tom Smith's name at the group header level, but when I drag "level date" into the group header, that date becomes FIXED to the first printed detail record's level date. That means all 3 groupheader dates (level dates I'm trying to fill), all say January 15th 2013.

How can I get all 3 squeezed into some type of group header.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Apr 2013 at 7:25am

teh only way to get them into a GH is to use a sub report, but you may consder using a GF. If you are suppressing all your detial sections, you can also suppress the GH and as fas as an end user would view the report there woul dbe no difference inusing the GF over the GH.

you would have to use shared variables to string togther the text to display.
IP IP Logged
mrtj
Newbie
Newbie


Joined: 26 Mar 2013
Online Status: Offline
Posts: 26
Quote mrtj Replybullet Posted: 19 Apr 2013 at 8:59am
Originally posted by DBlank

teh only way to get them into a GH is to use a sub report, but you may consder using a GF. If you are suppressing all your detial sections, you can also suppress the GH and as fas as an end user would view the report there woul dbe no difference inusing the GF over the GH.

you would have to use shared variables to string togther the text to display.

How to use shared variables?
each person may or may not have 3 levels.
I thought I could write 3 formulas for each level's date

Shared DateTimeVar levDate1;
if {QueryCombine.Level}=1 then
 levDate1:={QueryCombine.DateBegin};
//then call it out so it will be displayed, when you drag formula to footer
levDate1;

repeat for each level, using same DateBegin on the right side of assignment.
Now I've loaded a date into a variable.
Now the problem is the 2nd person's (2nd group) does not have a level 2 record, so the report prints person 1's level 2 date. I know there is a way to clear out a variable, but changing a date to a blank is a elaborate project in Crystal because you can't "make it null"

If someone answers the problem of dates not being cleared, I can move onto my next question. I may end up putting the 3 dates in a footnote, then I won't have to deal with more groupheader programming logic elaboration.





Edited by mrtj - 19 Apr 2013 at 9:11am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Apr 2013 at 9:21am
you have to convert the date field to a string and add the string values on each row together then display the final string result in the footer.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 19 Apr 2013 at 10:32am
Also, at the beginning of each person you have to have a formula that will reset all of the variables to blank.  Assuming that you change your existing formula so that it will return a string:
Shared StringVar levDate1;
if {QueryCombine.Level}=1 then
levDate1:=ToText({QueryCombine.DateBegin},'MM/dd/yyyy');
//then call it out so it will be displayed, when you drag formula to footer
levDate1
 
The reset formula would look like this:
 
Shared StringVar levDate1 = "";
 
Put this formula in a group header section ABOVE where you want to display the variable results.  This can be a blank group header "a" section that is suppressed - the formulas will still evaluate.
 
-Dell
IP IP Logged
mrtj
Newbie
Newbie


Joined: 26 Mar 2013
Online Status: Offline
Posts: 26
Quote mrtj Replybullet Posted: 22 Apr 2013 at 3:22am
OMG. (updated here after I wrote the stuff below the equal signs). Its working now. All this jibber jab below worked once I added a detail b line with the lev1date lev2date lev3date suppressed.
Thanks for your help


=================================
I changed databases on Friday because the systems guy invented a new view. Now all the fields come to me as string variables.

Shared StringVar lev1Date = ""; in group header (thanks)
Shared StringVar lev2Date = ""; in group header
Shared StringVar lev3Date = ""; in group header
I have a question on the above 3 statements. I'm semi-programmer literate, but i thought re-declaring a variable always resets it and wipes out info left in it from the last footer? Maybe not.

 I want to print the 3 dates on 3 different lines.
The level is a text field converted to a number.

in detail, 3 formulas, each called into the group footer: I wrote it without + signs at first just to see what is going on. It works sporadically.
Some level 1 ,2,3 fields are blank when I get to the third student for examp.
I think all my assign statements and clear statements are only engaging on the first record of a student, so if a level 1 date is his first record, then my (if statement for level 2) never engages.

I don't know how/when the header/footer formulas engage.
I'm a top-down kind of programmer.


shared stringVar lev1date;
if {@ph_txt_num}=1 then  lev1date:={view_Start_Date};
lev1date;

shared stringVar lev2date;
if {@ph_txt_num}=2 then  lev2date:={view_Start_Date};
lev2date;

shared stringVar lev3date;
if {@ph_txt_num}=3 then  lev3date:={view_Start_Date};
lev3date;



Now to get it to work.

Data :
Logan    3/16/2013 level 1
Isabella 10/31/2012 level 1, 1/30/2013 level 2
Chad     10/30/2012 level 1
Cailey    5/16/2012 l1
              8/8/2012  l2
              10/24/2012 l3
its printing Logan fine, because its first data piece
Isabella only the 10/31 info
Chad  only the 10/30 info
Cailey  no level 1 or level 3 is printing, just level2 date
so its only printing 1 level date per person, and it leaves the other 2 date fields blank, but for Cailey its the 2nd because the 5/16/2012 line is suppressed (for other reasons I have an overall filter that suppressed pre october 2012 lines)



Edited by mrtj - 22 Apr 2013 at 4:41am
IP IP Logged
mrtj
Newbie
Newbie


Joined: 26 Mar 2013
Online Status: Offline
Posts: 26
Quote mrtj Replybullet Posted: 22 Apr 2013 at 9:31am
I am moving onto the next item to report on.
I have some "tests" that take more than 1 date to complete,
but I only want to count the test as one item. I can do this with "distinct count", this is working fine, when I look at say jan 1- thru mar 31.
But if a test was split between Feb and March, then it gets counted in both months when you add the subtotals separately.

Ie test1 in jan
test2 in feb
test2 in mar
test3 in mar.
The quarter total is 3, but the monthly total is
jan 1
feb 1
march 2
(totals to 4)

I see the distinct count is doing what its supposed to do. Is the only work around to write some extra logic that in March ad "(not count test2)", then add that to the formula?


IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 22 Apr 2013 at 10:30am
This will get much more complicated.  How are your SQL Skills?  You'll have to write a Command, which is just a SQL Select statement, to get the filtering correct as there is no easy way I can think of to do this using just Crystal formulas.
 
-Dell
IP IP Logged
mrtj
Newbie
Newbie


Joined: 26 Mar 2013
Online Status: Offline
Posts: 26
Quote mrtj Replybullet Posted: 23 Apr 2013 at 3:46am
Originally posted by mrtj



Ie test1 in jan
test2 in feb
test2 in mar
test3 in mar.
The quarter total is 3, but the monthly total is
jan 1
feb 1
march 2
(totals to 4)



When this happens, I plan to print an asterisk in the group footnote section, and leave it count as 2 for march.
However, the formula for this footnote is not working on the second student. To test this formula, I temporarily inserted it into the header section (which is suppressed normally), and it works there.

shared stringvar asterisk;
if 
{@ph_txt_num}>1 and ({vw_Start_Date}="03/13/2013" or
{vw_Start_Date}="03/20/2013" or
{vw_Start_Date}="03/27/2013") then asterisk :="*"


then in header i also clear it out
shared stringvar asterisk:=""

One student who has a 3/13/2013 date prints the asterisk, the second does not. I have opened the data in excel to ensure no trailing spaces, and have added the trim function around this string date field but still it does not print * . The asterisk also will print in the detail section when I unsuppress detail and insert asterisk formula there.

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 23 Apr 2013 at 4:51am
How many dates does the student have?  In the group footer, it will only look at the very last detail record for the student - not at all of them.
 
-Dell
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.016 seconds.