Characters in IIF statements

  • Hi All

    Im using BIDS to design a report.

    In a calculated field I am using the below statement:

    =iif(Fields!COSTYPE.Value = M,"Available", "Reconciled")

    But it keeps errors on the M Character.

    Ive checked the character definately exsist in the field and I have tried "" '' {} [] around the M to no avail. Just says unidentified Character.

    How ever if i put a number there, any random number its ok.

    any Advise?

    Thanks

    R

  • All the sites I'm seeing show that the conditional variable, if characters, needs to be in quotes.

    =iif(Fields!COSTYPE.Value = "M","Available","Reconciled")

    looks like the right syntax.

    (not an ssrs expert)

    perhaps it's a data type error, hence the error for "M" and not numbers. maybe convert the field before evaluation?

    ______________________________________________________________________________________________
    Forum posting etiquette.[/url] Get your answers faster.

  • How would I convert it to string, Ive tried var(Field) and char(field) to no avail.

  • format(expression,[optional string format])

    So perhaps you could format the whole thing like this?

    =iif(format(Fields!COSTYPE.Value = "M","Available","Reconciled"))

    I believe format is the appropriate function.

    Again, I'm just trying to throw ideas out there until someone more knowledgable comes along. This is the kind of thing that I would spend a while playing with until I got it to work.

    ______________________________________________________________________________________________
    Forum posting etiquette.[/url] Get your answers faster.

  • thanks, the reason I needed it as a field was so I could group, but I found if I can create a group by an expression, so I added the oringal coe =iif(Fields!COSTYPE.Value = M,"Available", "Reconciled") as a group expression and it worked!

  • Hooray! I'll do a celebratory happy dance for your success. Glad you got it working.

    ______________________________________________________________________________________________
    Forum posting etiquette.[/url] Get your answers faster.

  • I know after looking at it for ages I feel relieved.

    But it is still would be a problem if i wanted to use this code as a field on the report.

    So if anyone has any ideas please do share!

    Thanks

    R

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply