Expressions (with Where clause?) to Build Calculated Column
Hi All- I thought perhaps what I wanted to do was simple, but I can't figure it out, so I'm hoping someone will give me some tips. I have a dataset coming in with multiple years of data for employment figures. I have the year and the geography set as parameters. the user chooses the year and the state (or multiple years and states) and can see some statistical data. One of the columns displayed is Employment (or # of Jobs). What I am attempting to do is add a calculated column that will show me the 1 year pct change in Jobs. If the user selects 2009, then the report would dynamically create the change. I thought perhaps I could create an expression for that column that looks something like below =(sum(Fields!empl.Value) where Fields!year.Value = @year - sum(Fields!empl.Value) where Fields!year.Value = @year - 1) / sum(Fields!empl.Value) where Fields!year.Value = @year - 1 I am relatively new to SSRS - so I apologize in advance if I haven't given you the appropriate information that will allow you to help with this inquiry, but any advice that you can give me would be GREATLY appreciated. This type of calculation is something that we want to do often. I know that I can add a 1 year % change to my dataset and pull it through - however, I want the change to be dynamic based on the year that the user selects from the report interface. Thanks so much in advance for your help. bethany
November 23rd, 2010 2:55pm

Use IFF where you want to use WHERE Like IIF(Fields!year.Value = @year,sum(Fields!empl.Value) , DoSomthingElse) Its IIF( Bolean Expression,True ,False) You can have nested IIF as well and you can have CASE as well just serch for syntex Gaurav Gupta http://sqlservermsbiblog.blogspot.com/
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 2:59pm

I could not get the IIF statement to work - I'm not sure why, but I don't think it was appropriate anyway. I ended up querying out the change and using the year parameters in the query and got the desired results. :) thanks so much for the response tho - I DO appreciate it!! Bethany
November 29th, 2010 1:55pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics