Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Syntax for IF Then ElseIf expression

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2005-07-27 : 16:13:23
Anyone have an example on how to write an IF Then ElseIF statement?
I can't get the syntax.

Thanks!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-27 : 16:20:33
You'll need to use IIf if this is in an expression in Reporting Services. If you are writing it in the custom code section, then the syntax is VB.NET syntax.

Tara
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-07-27 : 18:18:10
[rs expression syntax]
=IIF(Parameters!MyParam.Value = "blah", 1, 0)
[/rs expression syntax]

If the condition is true it returns 1 else 0, if you need multiple iif's just nest them:

=IIF(Condition, 1, IIF(Condition, 1, 0))

[vb.net syntax]
If Condition Then
'do something
else
'do something else
end if
[/vb.net syntax]

If you need multiple else's:

If Condition then
'do something
elseif Condition then
'do something else
else
end if

Jon



Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2005-07-27 : 18:30:16
Thanks to both of you!
I think I'm going to need to write the code in the Code section.
How do I call that code in an expression?

Thanks!
Go to Top of Page
   

- Advertisement -