Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Dynemic Grouping in SQL Server Reporting Services 2012 Expand / Collapse
Author
Message
Posted Monday, August 25, 2014 6:41 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 3:11 AM
Points: 1, Visits: 18
Hello All,

I am developing a report that have parameter like

RowGroupLevel1,
RowGroupLevel2,
ColumnGroupLevel1,
ColumnGroupLevel2,
ColumnGroupLevel3

Row Group Contain Category, Executive Name, Client Name Like Field
Column Group Contain Year,Quarter,Month Field.

So My requirement is as like except Level1 in Row and Column Grouping other fields are optional.


For An Example : if I am selecting as below

scenario 1 :
RowGroupLevel1 -> Category
RowGroupLevel2 -> Executive Name
ColumnGroupLevel1 -> Year
ColumnGroupLevel2 -> Quaker
ColumnGroupLevel3 -> Month

scenario 2 :
RowGroupLevel1 -> Category
RowGroupLevel2 ->
ColumnGroupLevel1 -> Year
ColumnGroupLevel2 -> Month
ColumnGroupLevel3 ->

so as per above scenario how I can grouping my report dynamically.

Please help me to create any type of SSRS report.


Thanks in advance.
Ankit Gusani
Post #1607039
Posted Wednesday, August 27, 2014 8:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 29, 2014 7:11 AM
Points: 5, Visits: 13
Hi.
I am using a procedure or just a SQL-Statement like this:
select 
-- dynamic row-grouplevel 1
case
when @paramRowGroupLevel1 = 1 then t1.Category
when @paramRowGroupLevel1 = 2 then t1.ExecutiveName
when @paramRowGroupLevel1 = 3 then t1.ClientName
when @paramRowGroupLevel1 = 4 then ''
else ''
end AS GroupRow1,
-- dynamic row-grouplevel 2
case
when @paramRowGroupLevel2 = 1 then t1.Category
when @paramRowGroupLevel2 = 2 then t1.ExecutiveName
when @paramRowGroupLevel2 = 3 then t1.ClientName
when @paramRowGroupLevel2 = 4 then ''
else ''
end AS GroupRow2,
-- dynamic col-grouplevel 1
-- analog to the row-grouplevel
sum( t1.sales ) sales
from
salestable t1
where
year = @paramYear
-- (and ...)
group by
case
when @paramRowGroupLevel1 = 1 then t1.Category
when @paramRowGroupLevel1 = 2 then t1.ExecutiveName
when @paramRowGroupLevel1 = 3 then t1.ClientName
when @paramRowGroupLevel1 = 4 then ''
else ''
end,
-- dynamic row-grouplevel 2
case
when @paramRowGroupLevel2 = 1 then t1.Category
when @paramRowGroupLevel2 = 2 then t1.ExecutiveName
when @paramRowGroupLevel2 = 3 then t1.ClientName
when @paramRowGroupLevel2 = 4 then ''
else ''
end
-- dynamic col-grouplevel 1
-- analog to the row-grouplevel


In the report the field GroupRow1 is the first grouped row. GroupRow2 is the second.
If you wish to suppress the rows with empty values for GroupRow1 or GroupRow2 you could calculate the row-hidden-attribute.

Hope this helps
.akoeli
Post #1607854
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse