SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Dynemic Grouping in SQL Server Reporting Services 2012


Dynemic Grouping in SQL Server Reporting Services 2012

Author
Message
ankit.gusani
ankit.gusani
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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
akoeli
akoeli
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 19
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search