Question

I'm trying to create an ssrs report where the parent grouping has 2 different sets of details, I can't seem to figure out how to display the unique details below the parent row

example:

table1
master
master1
master2

table2
master,  hand
master1, hand1
master1, hand2
master2, hand1
master2, hand2

table3
master, foot
master1, foot1
master1, foot2
master2, foot1
master2, foot2

my sql query is as follows

select t1.master, t2.hand, t3.foot
from table1 t1 
left outer join table2 t2 on t1.master = t2.master
left outer join table2 t3 on t1.master = t3.master

I want the ssrs report output to be

master1
hand1
hand2
foot1
foot2

master2
hand1
hand2
foot1
foot2

so far I've been able to get

master1
hand1
hand2
master2
hand1
hand2

but as soon as I try to add another row to display foot it links to the hand not master so it appears like this

master1
hand1
foot1
hand1
foot2
hand2
foot1
hand2
foot2

master2
hand1
foot1
hand1
foot2
hand2
foot1
hand2
foot2

if i add another row outside the grouping it only shows the first row from table3

master1
hand1
hand2
foot1

master2
hand1
hand2
foot1
Was it helpful?

Solution

With your data:

enter image description here

Starting with a master group and child group based on hand:

enter image description here

add an adjacent group to the hand group, but group on foot this time:

enter image description here

enter image description here

The tablix looks something like this now:

enter image description here

Which gives the required results:

enter image description here

OTHER TIPS

Best idea is to change the structure of your data. Rather than joining all three tables, do two separate queries (1 for t2 and 1 for t3) and union them together, then you get your data in rows and it's much easier to group. You'll need to sort the details group by tableName

select t1.id, t2.detail, 't2' tableName from (
select 'master' id union
select 'master1' id union
select 'master2' id) t1
left outer join
(
select 'master' id,  'hand' detail union
select 'master1' id, 'hand1' detail union
select 'master1' id, 'hand2' detail union
select 'master2' id, 'hand1' detail union
select 'master2' id, 'hand2' detail )t2
on t1.id = t2.id

UNION

select t1.id, t3.detail, 't3' tableName from (
select 'master' id union
select 'master1' id union
select 'master2' id) t1
left outer join
(
select 'master' id, 'foot' detail union
select 'master1' id, 'foot1' detail union
select 'master1' id, 'foot2' detail union
select 'master2' id, 'foot1' detail union
select 'master2' id, 'foot2' detail)t3
on t1.id = t3.id

groupingExample2

Result is

Grouping result

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top