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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple conditions in IIF statement

Status
Not open for further replies.

acessn

Programmer
Feb 16, 2005
71
0
0
NO
Hi.

Using visual studio 2005 with SQL 2005 reporting Services.

I'm trying to create an expression to check for multiple conditions. Basically I'm doing a sum on TIMEINSECONDS if a paycodeid is 123, 124, 125, 126 or 127.

In Crystal I would create a running total and say something like
Code:
if {paycodeid} in [123,124,125,126,127] then do something.

Is there an equivalant to this approach in Reporting Services?

I have tried this
Code:
=IIF
(
(
Fields!PAYCODEID.Value =(123) or 
Fields!PAYCODEID.Value =(124) or
Fields!PAYCODEID.Value =(125) or
Fields!PAYCODEID.Value =(126) or
Fields!PAYCODEID.Value =(127) 
)
,Fields!TIMEINSECONDS.Value/3600.00
,0.00
)

This returns the following error: [BC30455]Argument not specified for 'Falsepart' of 'Public Function(Iif(Expression As Boolean, Truepart As Object, Falsepart As Object) As Object'.

Any ideas?


Thanks,
Bjorn
 
Too many brackets:

=IIF
(
Fields!PAYCODEID.Value =123 or
Fields!PAYCODEID.Value =124 or
Fields!PAYCODEID.Value =125 or
Fields!PAYCODEID.Value =126 or
Fields!PAYCODEID.Value =127
,Fields!TIMEINSECONDS.Value/3600.00
,0.00
)


Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Hi Geoff,

That didn't work, but I solved it by using a workaround with assigning all paycodeids to a string and used instr() within the IIF.

It also worked with a switch statement.

Thanks for your time!

Regards,
Bjorn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top