Search code examples
reporting-servicesssrs-2008ssrs-2012reportingservices-2005iif-function

Error in SSRS expression for false condition


I want to generate my string in the following format:

Vancouer should be displayed as -> ( V) anc-ouer
Roberts Cut-Off Road -> Roberts Cu(t-O) ff-Road ... etc So for the last 4 charaters I am using:

Right(Fields!NAME.Value, 4)

for the middle portion I am using IIF :

IIF(Len(Fields!NAME.Value) < 10, 
Left(Fields!NAME.Value,. 
(Len(Fields!NAME.Value)-7)), 
 Mid(Fields!NAME.Value,Len(Fields!NAME.Value)-9,3))

But the above IIF condition gives me #Error whenever the length is less than 10. What could be the possible solution for it? Or its better if I could know the expression to generate the complete format in easiest way possible.


Solution

  • Even if you have the condition to check for 10 characters SSRS still evaluates the false part which is why you are getting the error, this is normally encountered when attempting to avoid divide by zero errors. more info here

    divide by zero/null workaround

    another article