question

Moz avatar image
Moz asked

SSRS Expression Error

Hi, I am new to writing expressions and am having some trouble with the following code: = IIf(Instr(CStr((Fields!Seconds_In_Dept.Value/60)/60),".") <> 0, Left(CStr((Fields!Seconds_In_Dept.Value/60)/60), Instr(CStr((FieldsSeconds_In_Dept.Value/60)/60),".") [b]- 1[/b]) + " Hours " + CStr( (Fields!Seconds_In_Dept.Value/60) mod 60) + " Minutes", "Test") Most values evaluate fine with this expression. When the Seconds_In_Dept is 3600 i.e an hour exactly though I get an #Error. I was using the IIf to deal with this as the InStr functions evaluates to 0 for 3600 seconds. I still get the error though as I think the Left function takes the value - 1 for the row with 3600 seconds. I'm not sure why this should happen as the IIf tests for a value of 0 for the InStr function and so I would expect the string "Test" to be returned for the 3600 seconds. Any ideas much appreciated, Dave.
ssrsssrs-2008errorexpression
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
KenJ avatar image
KenJ answered
It looks like `Fields!Seconds_In_Dept` in the else portion of your IIF may be missing an exclamation mark (every other reference has one) Instr(CStr((FieldsSeconds_In_Dept.Value/60)/60),".") [b]- 1[/b]) versus Instr(CStr((Fields!Seconds_In_Dept.Value/60)/60),".") [b]- 1[/b]) This would only break on the hour when you fell into the else (3600 seconds).
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.