Solved

creating conditional groups in SSRS

Posted on 2010-11-14
5
1,068 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
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:Yurich
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hi All, I am here to write a simple article to move SSRS (SQL Server Reporting Services) reports from one server to another. When I have faced the same issue to move reports those were developed by developer on development server and now need to …
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now