Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"parent/child" displaying 1

Status
Not open for further replies.

HoosHot

Programmer
Jan 16, 2003
41
US
Hi,

By parent/child, I mean something hierachical like account and sub-account.

I have data like the following. When parent and child are the same and you don't see any other rows, it means this parent basically does not have children. Parent and child are key/id columns. Amount is just a number field.
parent child amount
------ ----- ------
10 10 9
20 20 3
20 30 6
20 40 1

Let's assume that page 1 shows 10/10, page 2 shows 20/20, page 3 shows 20/30, page 4 shows 20/40.

In a crystal report, I have parent as group-header-1 and child as group-header-2. I have child in group-header-2 section. I, however, want to supress child when the parent and child are the same, and there are no more children. Put another way, if parent and child are the same, and there are more children, then show. In the example above, on page 1, I don't want the child 10 to show. On page 2, I do want child 20 to show. On page 3, I do want child 30 to show. On page 4, I want child 40 to show.

Right now, my group supression formula is:
parent = child
and
count(child) > 1

good - page 1 does not show child
bad - page 2 does not show child (I want child to show here)
good - page 3 shows child
good - page 4 shows child

I've played around with the AND and the >, doing different combinations of and/or/>/= and I just can't get the result I want.

Is there anything else I can provide to you to help me?

Thanks so much :)
 
I'm confused with your logic.

You state if parent and child are same don't show.

Page 2, which is 20/20 is parent child the same, and should not show if I am understanding your stated logic, but you say you want it to show.

Am I not understanding your needs?

Also, did you check out hierachical grouping option.

Report/Hierarchical Grouping Options

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Hey Rosemary,

I think HoosHot wants to see the 20/20 relationship because 20 is one of other children, whereas in the 10/10 relationship, 10 has no other children to display.

HoosHot, try and base your suppression logic on the following:

Parent = Child and
Parent <> Next(Parent)

This should suppress 10, but not 20, based on your example. It should continue to be effective as long as the minimum child for any parent can never be a smaller number than the parent, thus enabling later children to be the same number as the parent.

All the best,

Naith
 
Hi,

Naith, I see what you are trying to do. However, it does not work because I have many rows of each parent/child. Let me show you more data so it's more representative of my real data.

parent child amount
------ ----- ------
10 10 1
10 10 2
10 10 3
20 20 1
20 20 2
20 20 3
20 20 4
20 20 5
20 20 6
20 30 1
20 30 2
20 30 3
20 30 4
20 30 5
20 30 6
20 30 7
20 30 8
20 40 1
20 40 2

On page 1, I'd like to show:
parent <no child> amount
------ ---------- ------
10 1
10 2
10 3

On page 2, I'd like to show:
parent child amount
------ ----- ------
20 20 1
20 20 2
20 20 3
20 20 4
20 20 5
20 20 6

On page 3, I'd like to show:
parent child amount
------ ----- ------
20 30 1
20 30 2
20 30 3
20 30 4
20 30 5
20 30 6
20 30 7
20 30 8

On page 4, I'd like to show:
parent child amount
------ ----- ------
20 40 1
20 40 2

Thanks so much for everybody's help :)
 
I think that you'll need a subreport to handle this, or better yet, do it on the database in SQL.

In CR, the main report will count the number of distinct parent child combinations, you'll now know at print time
whether the (distinct) count of the children for each parent is greater than 1, and you can pass a boolean shared variable to the subreport to be used as the child suppression formula.

-k kai@informeddatadecisions.com
 
My bad, HoosHot.

I didn't consider that there could be numerous instances of parents and children with the same id, like in your 10 group.

Change your suppression logic to this:

Parent = Child and
Count({Child},{Parent}) = 1

You don't need subreports.

Naith
 
Thanks, Naith.

I had to change around the logic just a tiny bit. This works:
Parent = Child
And
DistinctCount({Child},{Parent}) = 1

You are my hero! Thanks a bunch :)
 
Very nice job Naith <warm smile and star for you!)

Sorry I didn't see it sooner - I have been a consulting fool...way too many hours in the last 8 days.

Nice job to you to HoosHot...I guess you are!
ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top