5

I've got a 1:Many relationship between a Parent object and Child object (master detail). I want to write a report that will show each parent object in its own row, with columns for each child record. Is this possible?

Data:

    ParentA
       |
  +----+----+
  |         |
ChildA    ChildB

Desired report output:

Parent Name | Child Name | Child Name | ...(up to n children)
-------------------------------------------------------------
Parent A    | Child A    | Child B    | ...
Parent B    | Child C    | Child D    | ...
2
  • Would a summary report on the child grouped by Parent do it ? Eg Contacts grouped by Account. Jun 10 '13 at 21:04
  • Unfortunately, my requirements are that the Children be in the same row of a 2-D table. I guess I'll have to do this manually. Thanks for the suggestion! Jun 10 '13 at 21:31
1

Excellent question.

With basic reporting capabilities - no. As far as I know SF doesn't offer any way to pivot (turn rows into columns) in SOQL, Apex and in the reporting engine.

If you have a field that's unique for kids of one parent (ideally some sequential number) you could try faking it by using a bucket field in the report. You'd throw all "kid 1" records into 1st bucket etc... Sounds like it'd require extra preparations / data fixes on your side.

(You're bit more lucky if your child records are created for example once a month - date fields can be pretty neatly grouped in summary & matrix reports).

Other than that - you might be forced to transform your data yourself. Create a helper object with these duplicated columns and try to fill it in, either with an Analytic Snapshot or with some batch job?

2
  • I don't think bucketing is going to work for me. My requirements need the 2-D table structure laid out in the question. I suppose I will have to do it manually, as you say. Thanks for the suggestions! I'll mark you correct in a while if no one can offer a better solution. Jun 10 '13 at 21:37
  • Agreed with eyescream, there's not a way to do this with the Salesforce reporting engine short of actually transforming the data into a second object and storing it twice. Might want to look at the Excel Connector and pull this data directly into Excel, then put it into pivot tables. Jul 11 '13 at 0:12
0

This may give you something which may help point you in a direction that might be fruitful. Whether it provides a solution, I can't say for certain because you want to go to "n" children, which it sounds as though is an indeterminant number.

If you create a Matrix report, you can group things both by columns and by rows. You can also use cross filters to report on related objects which may be the way to get all of the children added into your report (you can also do the cross filters in other kinds of reports too, particularly joined reports). For more on creating reports, I'd recommend taking a look at Chap 10 of Force.com Platform Fundamentals. There's also the Analytics Workbook which may be of some help as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.