How to set a dynamic category in the charts:
Sometimes there is a requirement where we want to analyze the data based on different dimensions at run time.
So it’s like at run time we can analyze the same measure with different dimensions.
Solution:
We can achieve this by using a filter in the report which allows the user to select the dimension against which they want to analyze the data (Measures) at run time and using this value in the charts “category group” to dynamically set the values.
Create a data set for the filter:
- Filter for the Dimension Names: for Example
SELECT 'DepartmentGroupName' AS Dimension
SELECT 'OrganizationName' AS Dimension
SELECT 'ScenarioName' AS Dimension
Create a data set for the Report data:
- Data for the Report: for example(Just selecting the top 1000 rows for the demo)
SELECT
TOP 1000
DDG.DepartmentGroupName,
DO.OrganizationName,
DS.ScenarioName,
FF.Amount
FROM
dbo.FactFinance as FF
INNER JOIN dbo.DimDepartmentGroup DDG
ON FF.DepartmentGroupKey = DDG.DepartmentGroupKey
INNER JOIN dbo.DimOrganization DO
ON FF.OrganizationKey = DO.OrganizationKey
INNER JOIN dbo.DimScenario DS
ON FF.ScenarioKey = DS.ScenarioKey
- Report Layout:
a. Add a parameter in the Report:
b. Specify the available value from the Dataset which returns the names of different Dimensions list.
c. Specify a default value for the Dim Parameter. For example “DepartmentGroupName”
d. In the Report layout add a chart:
For example a column chart
In the chart, Values select the measure which you want to analyze (e.g. Sum (Amount))
In the category Groups write an expression on “Group on” and “label” like:
=iif(Parameters!Dim.Value="DepartmentGroupName",Fields!DepartmentGroupName.Value,iif(Parameters!Dim.Value="OrganizationName",Fields!OrganizationName.Value,iif(Parameters!Dim.Value="ScenarioName",Fields!ScenarioName.Value,Nothing)))
In the chart title and X-axis Label use the Parameter value to dynamically change the values to be displayed in the chart.
- Preview the Report:
- Change the value in the filter to “OrganizationName” and run the report:
We can use the same approach for the Measures also and the chart will be totally dynamic!!
Note: Report data is taken from the AdventureWorksDW2008R2 sample database!
Thanks a lot sir! such simple & clear guidance!
ReplyDeleteHi Sir,
ReplyDeleteI am just learning ssrs and I have been given a task to achieve wherein if there is total population of india is shown on pie chart state wise like UP,BIHAR,PUNJAB,MP etc if I click on one of the state then it should take me to another pie chart showing the population city wise for eg.If I click on UP state then it should take me another pie charts showing the population in cities in Up like merut,lucknow & allhabad and then if I click on one of the city then it should take me another pie charts showing the population of the cities area wise so basically its like drill down report but purely pie chart .Can we achieve that in SSRS like power view in ms excel? Please reply this
Great tutorial, fully solved my requirements.
ReplyDeleteThanks a lot !!! :)