Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with Iif/Case/Switch/InStr expression (calculated field)

Status
Not open for further replies.

dianemarie

Instructor
Jul 11, 2001
583
US
Hello, I want to take this SQL and put it into a calculated field in my report (SSRS 2005). I'm showing customer categories on a report, and they want to take categories that are broken out into several subcategoris and throw them into one category. (Ex: there is Fundraising-Health, Fundraising-Kids, etc. which they want together under "Fundraising".) I have tried Iif, Switch, Instr. They all look OK but when I drop the expression on the report and run the report, the field returns #Error. I see on the internet that doing a public function might help, but I'm unsure how to write it. Category is a varchar 100 field in the table. Any help would be appreciated.

case when account_type like 'fundraising%' then 'Fundraising'
when account_type like 'magazine%' then 'Magazines'
when account_type like 'apparel%' then 'Apparel' else account_type end as cats
 
OK, I'm good. It was a simple user error. I neglected to remove the SUM that was inserted automatically when I dragged the calculated field. (Not the first time either.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top