Solved

creating conditional groups in SSRS

Posted on 2010-11-14
5
1,072 Views
Last Modified: 2012-06-21
Hello Experts,

I need to create 3 different groups in my report, based on a condition:

Group 1 -  AccountNumber like '400%'
Group 2 - AccountNumber like '42%' and '43%'
Group 3 - AccountNumber = '47100'

Can someone tell me how and where in SSRS I do this and what the syntax should be?

Thanks.
0
Comment
Question by:erp1022
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:Yurich
ID: 34132006
Hello,

I presume your account number is your parameter (otherwise it will not work).
You can create conditional groups like that:

- In  your report, select a detail row, right click it and select Insert Group
- In the Group On area, select <Expression...>
- In the expression use the similar syntax:

=IIF( Parameters!AccountNumber.Value LIKE "400", Fields!Field1.Value,
 IIF( Parameters!AccountNumber.Value LIKE '42' OR Parameters!AccountNumber.Value LIKE '43', Fields!Field2.Value,
 IIF( Parameters!AccountNumber.Value = '47100', Fields!Field3.Value, Fields!Field4.Value )))

Field4 - is the field for all other accounts, but if your conditions cover all cases, then you can use this syntax:


=IIF( Parameters!AccountNumber.Value LIKE "400", Fields!Field1.Value,
 IIF( Parameters!AccountNumber.Value LIKE '42' OR Parameters!AccountNumber.Value LIKE '43', Fields!Field2.Value, Fields!Field3.Value ))

That should be all,
Good luck :)
0
 

Author Comment

by:erp1022
ID: 34132213
Hi,

Thanks for your response. No, I hadn't actually set up a parameter, I did not know that was required. I have worked with Crystal a lot and have just started working with SSRS, so please bear with me :)

So if I set up a parameter does that mean that the end user running the report will have to enter (or select) an account at runtime?

If so, is there another way to do this? I have no other paramaters on my report and the end user should not have to select anything at runtime.

Thanks again!
0
 
LVL 21

Accepted Solution

by:
Yurich earned 500 total points
ID: 34132392
Hmmm...

I must have misunderstood what you really wanted to do. It seems to me that you don't actually want to create three groups, but rather one group (e.g. AccountType) with three (or four) values in it. In which case it's not done on the report side at all, but rather in your query.

Add an extra field to your query, similar to this:

SELECT...,
 CASE WHEN AccountNumber LIKE '400%' THEN 'AccountType1'
   WHEN( AccountNumber LIKE '42%' OR AccountNumber LIKE '43%' ) THEN 'AccountType2'
   WHEN AccountNumber = '47100' THEN 'AccountType3'
 ELSE 'AccountType4' as AccountType,
...


You can change values for the account types of course, and if you need AccountType4 only if your conditions do not cover all accounts (e.g. you can call it 'Other Accounts')

Then in the report, you can create one group and group it on the AccountType field. And that's it :)

Cheers


0
 

Author Comment

by:erp1022
ID: 34135549
This grouping thing in SSRS is not doing at all what I want it to do. What I want is to have three separate groups. Within those groups are the account numbers (based on the where condition) that show the revenue for whatever date range for that account number. So it would look like this:

GHS (these are the 400's)
     40010                          1,000.00
     40020                          5,000.00
     40030                          2,000.00
     and so on...
Total                                 8,000.00

HHG (these are the 42% and 43%)
     42000                         4,000.00
     42020                            100.00
     43000                         1,000.00
     and so on...
Total                                5,100.00

334 (this is the 47100)      500.00

Total Revenues              13,600.00


The account numbers pull a sum from the transactions table in the database based on the account number and date range.

The above I could do so easily in Crystal through the grouping function but this does not work similarly in SSRS. In Crystal I could insert different groups (based on the where condition) and add headers and footers to each group. Can you tell me how I should be doing this in SSRS?
0
 

Author Comment

by:erp1022
ID: 34136919
I think I got it, although it took a lot of playing around with it and trying different things. Thanks for your help!
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you'll probably know, a data region in a SQL Server Reporting Services report can be linked to only one dataset.  This makes it troublesome when you need to display data from more than one dataset in the same data region.  SQL Serve…
A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question