简体   繁体   中英

SSRS grouping chart by parameter

I have problem with grouping by parameter in my chart.

Let's assume query that gives data like below:

在此处输入图片说明

I would like to Group category in the cart based on parameter. Parameter has value City or Country but it can be also different (no possibility to define constant list) On the chart I should see (based on parameter):

Parameter: City

在此处输入图片说明

Parameter: Country

在此处输入图片说明

Is there any possibility to do it in SSRS?

You can do use an expression for group by :

select (case when parameter = 'City' then city
             when parameter = 'Country' then country
        end) as which,
       sum(value)
from t
group by (case when parameter = 'City' then city
               when parameter = 'Country' then country
          end);

That said, I think you should have separate queries in SSRS for the different values. Such parameterized queries are harder to optimize and harder to maintain.

Assuming your parameter has values of 0 and 1 where 0=Country and 1=City.... You just need to set the following items

  • The cell to be displayed ( in column 1 in your example)
  • The Group On expression of your row group
  • The Sort by expression of your row group

to the same expression, something like this...

=IIF(Parameters!groupColumn.Value =0, Fields!country.Value, Fields!city.Value)

Its the exact same expression in all three places.

If you can't get this working, let me know and I'll post an example but it's pretty simple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM