Solved

iif condition in ssrs

Posted on 2010-09-23
9
3,183 Views
Last Modified: 2012-06-27
Hi,
I have used the following expression in ssrs

=IIf((Fields!ASSET_ID_.Value) LIKE ("*LAB*","*SIGNUP*", "*QDISPLAY*", "*PUB*"),
"Public",
IIf(Fields!DEPARTMENT.Value = "Library"
AND (Fields!ASSET_ID_.Value) LIKE ("*LAP*"),
"Public","Not Public")

and it is giving the error
the value expression for the field ('=IIf((Fields!ASSET_ID_.Value) LIKE ("*LAB*","*SIGNUP*", "*QDISPLAY*", "*PUB*"),
"Public",
IIf(Fields!DEPARTMENT.Value = "Library"
AND (Fields!ASSET_ID_.Value) LIKE ("*LAP*"),
"Public","Not Public")
[BC30198]') expected.


Please help me!!
0
Comment
Question by:Mounikaa
  • 4
  • 3
  • 2
9 Comments
 

Author Comment

by:Mounikaa
ID: 33748941
Hello..

Is there any bode to help me!!!!
0
 
LVL 6

Expert Comment

by:CRJ2000
ID: 33749749
Is it possible that you're running into problems with null values? Try putting a test for IsNothing before everything else.... For example:

IIF(IsNothing(Fields!ASSET_ID.value),"Nothing",IIF(...

Chris
0
 

Author Comment

by:Mounikaa
ID: 33749944
The following expression worked for me.

=IIf((Fields!ASSET_ID_.Value) LIKE  ("*LAB*") AND (Fields!ASSET_ID_.Value) LIKE  ("*SIGNUP*")
AND (Fields!ASSET_ID_.Value) LIKE  ("*QDISPLAY*") AND (Fields!ASSET_ID_.Value) LIKE  ("*PUB*"), "Public",
IIf(Fields!DEPARTMENT.Value = "Library"
AND (Fields!ASSET_ID_.Value) LIKE ("%LAP%"),
"Public?" , "Not Public"))

But is there any simple way to do this.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Mounikaa
ID: 33749949
for all reesults I got "Not Public"

I don't know whether workin ina right way or not
0
 
LVL 6

Accepted Solution

by:
CRJ2000 earned 250 total points
ID: 33750018
Your latest has "%" as the wildcards, rather than the "*" that may be causing your issue with the "Not Public" always appearing. To check if your query is working correctly, make sure to pull back the Asset_Id field along with your calculated field.
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 33750029
try this please :

=IIf((Fields!ASSET_ID_.Value) LIKE  ("*LAB*") OR (Fields!ASSET_ID_.Value) LIKE  ("*SIGNUP*")
OR (Fields!ASSET_ID_.Value) LIKE  ("*QDISPLAY*") OR (Fields!ASSET_ID_.Value) LIKE  ("*PUB*"), "Public",
IIf(Fields!DEPARTMENT.Value = "Library" AND (Fields!ASSET_ID_.Value) LIKE ("%LAP%"),
"Public?" , "Not Public"))

But one question, do we not use % along with the LIKE everwhere in your query as similar to how you have to used in "%LAP%"

i am not sure, whether the below can be right... we need to use % as the wild card matching operator with LIKE..not sure why you had used * for some and % for only one. Test it out.

IIf((Fields!ASSET_ID_.Value) LIKE  ("%LAB%") OR (Fields!ASSET_ID_.Value) LIKE  ("%SIGNUP%")
OR (Fields!ASSET_ID_.Value) LIKE  ("%QDISPLAY%") OR (Fields!ASSET_ID_.Value) LIKE  ("%PUB%"), "Public",
IIf(Fields!DEPARTMENT.Value = "Library" AND (Fields!ASSET_ID_.Value) LIKE ("%LAP%"),
"Public?" , "Not Public"))

Thanks
0
 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 250 total points
ID: 33750036
if * is the wild card character which needs to be used in SSRS then replace the % with * in all the occurrances in the given query and give it a try.
0
 

Author Closing Comment

by:Mounikaa
ID: 33755418
Your comments helped me and I got a result.
0
 
LVL 6

Expert Comment

by:CRJ2000
ID: 33755559
Glad I could help, Mounikaa.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  ‚Ķ
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question