SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Characters in IIF statements


Characters in IIF statements

Author
Message
rkaria
rkaria
SSC Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 Visits: 193
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
calvo
calvo
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3422 Visits: 4018
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. Get your answers faster.
rkaria
rkaria
SSC Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 Visits: 193
How would I convert it to string, Ive tried var(Field) and char(field) to no avail.
calvo
calvo
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3422 Visits: 4018
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. Get your answers faster.
rkaria
rkaria
SSC Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 Visits: 193
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!
calvo
calvo
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3422 Visits: 4018
Hooray! I'll do a celebratory happy dance for your success. Glad you got it working.

______________________________________________________________________________________________
Forum posting etiquette. Get your answers faster.
rkaria
rkaria
SSC Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 Visits: 193
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search