Solved

iif condition in ssrs

Posted on 2010-09-23
9
3,066 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
Comment Utility
Hello..

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

Expert Comment

by:CRJ2000
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Mounikaa
Comment Utility
for all reesults I got "Not Public"

I don't know whether workin ina right way or not
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Accepted Solution

by:
CRJ2000 earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Your comments helped me and I got a result.
0
 
LVL 6

Expert Comment

by:CRJ2000
Comment Utility
Glad I could help, Mounikaa.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now