Solved

creating conditional groups in SSRS

Posted on 2010-11-14
5
1,073 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Written by Valentino Vranken. A while ago I wrote an article called Chart Optimization Tips (http://www.experts-exchange.com/articles/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Chart-Optimization-Tips.html).  This article explained how …
How to use Variables  and Custom code in SSRS report and Assembly reference to use compile shared code in SSRS. Its big question for all who are working with SSRS. It is easy to create assembly and refer in SSRS report, still there are some steps…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

627 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