Link to home
Start Free TrialLog in
Avatar of erp1022
erp1022Flag for United States of America

asked on

creating conditional groups in SSRS

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.
Avatar of Yurich
Yurich
Flag of New Zealand image

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 :)
Avatar of erp1022

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of Yurich
Yurich
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of erp1022

ASKER

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?
Avatar of erp1022

ASKER

I think I got it, although it took a lot of playing around with it and trying different things. Thanks for your help!