Link to home
Start Free TrialLog in
Avatar of rjthomes
rjthomes

asked on

Crystal Reports group header parent/child problem

I need some help with my first Crystal Report.

The group header shows as the first record of the group instead of the parent record that the child records are based on.

I have attached a .pdf identifying my challenge (I think).  Also included the .xls and .rpt I am working with.
Report2.rpt
SMARTSHEET.xls
Notes.pdf
Avatar of Mike McCracken
Mike McCracken

Can you explain the parent to child relation?
How do I know which are parent rows?

mlmcc
Avatar of rjthomes

ASKER

Thanks for the inquiry...  I apologize in advance if my terminology is a little off but here it goes.

You can't really identify if a record is a parent but you can identify if any record is a child.

If a record has a number in the "__row_parentRowNumber" field then it is a child of that row number.

If there is not a number in that field then it is possibly a parent record but not necessarily.

Does that help?
I have only looked at the PDF file.

 As I understand it, you have a group and you want the group header to show a value (the name) from one specific member of that group (the parent for the members of that group), instead of showing the value from each individual group.

 You said that if a record has a number in __row_parentRowNumber__, it is a child.  Otherwise, it may be a parent.

 But in the PDF file, you say that you want "City Of Palm Desert" in the header, implying that that is supposed to be the parent.  But that row has a 1 in __row_parentRowNumber__, which supposedly means that it's a child, not a parent.  It looks like maybe "Documents" should be the parent, but I can't be sure, because you put a note over where __row_parentRowNumber__ would be, so I don't know if there's a number there or not.


 Ignoring all of that for the moment, if you can come up with a test that will identify the parent records, you might be able to use something like the following.

 Let's say that you could identify a parent (or, at least, a "non-child") using:
__row_parentRowNumber__ = 0

 You could create a formula like the following (call it parent_name):
if {table.__row_parentRowNumber__} = 0 then
  {table.name field}
else
  ""

 Replace the field names with your actual field names, of course.
 That formula would only produce the name on the "parent" records.  It would produce an empty string on the child records.

 Then you could use a formula like the following to display the parent name:

Maximum ({@parent_name}, {group field})

 {group field} would be the group above the one with "Documents", "City of Palm Desert", etc.  In the PDF file, it looks like CAT_ENTITLEMENT and CAT_PURCHASE_SALE are part of a group above that one, so you'd probably use that field.

 James
James,

Thank you for your input so far.  I hope you can continue to be patient with me (I am such an amateur).

I took a look at my notes.pdf and it is correct (as I see it).

As part of CAT_ENTITLEMENT (group)

"Documents" is row number 1 and happens to be the parent of "City of Palm Desert".  It is not a child of anything so the parent row = ""

"City of Palm Desert" is row number 2 with a parent row of 1 (child of "Documents").

"City of Palm Desert" is the parent of...

Fee Schedule
Tentative Tract Map Application
Environmental Assessment Form
General Plan Amendment Application
Change of Zone Application
Architectural Review Application

but... "Fee Schedule" appears as the header of that group rather than "City of Palm Desert".

I chose "City of Palm Desert" for this discussion because it is both a parent and a child.

I am not sure that what you have offered so far quite gets me there.

My ultimate goal is to show like a summary...

Documents  
     City of Palm Desert
          Fee Schedule
          Tentative Tract Map Application
          Environmental Assessment Form
          General Plan Amendment Application
          Change of Zone Application
          Architectural Review Application


Does that help?  Any thoughts?

Chad
I just assumed that you wanted the top level parent for all of the records in the first group (CAT_ENTITLEMENT).  Trying to get the immediate (?) parent for each sub-group complicates things.

 What are the basic rules?  If something is a parent, you want to show its name, but if it's not a parent, you want to show its immediate parent's name?  For example, "Documents" and "City of Palm Desert" are parents, so you show their names on those lines.  But the children of "City of Palm Desert" are not parents, so you want to show their parent's name ("City of Palm Desert")?

 Could there be more levels of parent-child?  For example, could one of the children of "City of Palm Desert" also be a parent, with its own children records?  If so, does the child show its name, because it's also a parent, or does it show "City of Palm Desert"?  What about its children?  What do they show, their parent's name, or "City of Palm Desert" (their grandparent)?

 Are the parents and children always in that order (parent, then children)?  For example, in the PDF, you have "City of Palm Desert", and then its children.  Will it always be like that?

 Could there be more than one "significant" parent (like "City of Palm Desert") within a single main group?  For example, you have "City of Palm Desert" and some children in the CAT_ENTITLEMENT group.  Could there be more records in the CAT_ENTITLEMENT group that include another parent record (eg. "City of Tomorrow"), with its own children?

 If you could have more than one set of parent-child records in the same main group, would they be in order (parent 1 and its children, parent 2 and its children, etc.), or could the records be mixed up (eg. parent 1, children for parent 1 and 2, parent 2, children for parent 1 and 2)?

 James
OK, after I asked all of those questions, I really looked at your "ultimate goal" for the first time.  In that post, it _looks_ like you're basically just trying to indent each child level a bit more, as opposed to trying to display the parent's name (which you have to get from a different group).

 Is that true, or is there more to it than that?  If you're basically just trying to indent the records, based on the parent-child level, we may be able to come at this from a different direction.

 James
James,

Ok...  Lots of thoughts.

At the end of the day I am simply trying to display corresponding parents and children in a summary (with indents on each new level).

Like:

Documents  
     City of Palm Desert
          Fee Schedule
          Tentative Tract Map Application
          Environmental Assessment Form
          General Plan Amendment Application
          Change of Zone Application
          Architectural Review Application

Children of "City of Palm Desert" can be parents also.  It might look like this.

Documents  
     City of Palm Desert
          Fee Schedule
          Tentative Tract Map Application
               grand child 1
               grand child 2
                    great grand child 1
          Environmental Assessment Form
          General Plan Amendment Application
          Change of Zone Application
          Architectural Review Application
     City of Tomorrow
          child 1
               grand child 1
                    great grand child 1
etc.....

"Documents" is a top level record because it does not have a parent.

"CAT_ENTITLEMENT" is simply a field entry that the above are grouped by.

I don't mean to state what is probably obvious to you...

I believe that your understanding in your Post 2014-03-01 at 16:56:26 is accurate.

Chad
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
James,

The hierarchical grouping was exactly what I needed.

See attached.

Thank you for your help and patience.

Chad
Hierarchical-example.pdf
Outstanding patience and guidance.
Great.  I just wish I'd thought of it earlier, but, like I said, I've never used it, so it just didn't occur to me.  But at least we got there eventually.  :-)

 James