IF ELSEIF expression
Hello Friends,
I was trying something like this
F @ARTWRKTYP = 1
BEGIN
SET @IARTWRKTYP = 2
END
ELSE IF @ARTWRKTYP = 4
BEGIN
SET @IARTWRKTYP = 5
END
ELSE IF @ARTWRKTYP = 3
BEGIN
SET @IARTWRKTYP = 6
END
How can i put expression for parameter @IARTWRKTYP
I tried following expression:
=IIF(Parameters!ARTWRKTYP.Value=1,2,IIF(Parameters!ARTWRKTYP.Value=4,5,IIF(Parameters!ARTWRKTYP.Value=3,6,IIF(Parameters!ARTWRKTYP.Value=9,10,IIF(Parameters!ARTWRKTYP.Value=7,7,IIF(Parameters!ARTWRKTYP.Value=8,8,0))))))
but gives an error, any idea where I'm going wrong
June 10th, 2011 6:44am
You must be doing something wrong. I tried your code it worked just fine. What's the error you are getting?
Free Windows Admin Tool Kit Click here and download it now
June 10th, 2011 7:43am
It may be that the data source of the parameter may have leading or trailing blanks. Try putting a textbox
in your page header as follows and see what value is in your parameter.
="X"+Parameters!ARTWRKTYP.Value+"X"
If there are any spaces before or after the parameter value (between the value and the X's) you will need to trim the blanks.
Or it could be a data type issue. Perhaps ARTWRKTYP contains text.
Martina
http://dataqueen.unlimitedviz.comMartina White
June 11th, 2011 9:25pm
Hi,
If there is no Else part then I recommend to use a switch statement.
Thanks-------------------------------------------------------------------------------- Please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Maqbool.
Free Windows Admin Tool Kit Click here and download it now
June 12th, 2011 6:20am
Hi,
The expression looks good itself, it should work.
I have a small doubt is the parameter @IARTWRKTYP placed after parameter
@ARTWRKTYP? If not you will get forward dependency error.
Please check it once
Hope its clear & helpful....Pavan Kokkula Tata Consultancy Services.
June 13th, 2011 3:19am
Hi
Prashant,
Thanks for your question and other partners’ valuable replies, I have reproduced the scenario with your Expression, it works fine if I
defined the parameter ARTWRKTYP before the parameter IARTWRKTYP, however, it will be an error if
the parameter ARTWRKTYP below the parameter IARTWRKTYP, the Error message is: An error occurred during local report
processing IARTWRKTYP.
Do you have the same error? If so, the reason for this issue is that you listed the parameter IARTWRKTYP before its dependent on parameter ARTWRKTYP, please
follow below steps to change the parameters’ order,
1. In the Report Data window, click the parameter of
IARTWRKTYP.
2. Click the Move down button to move the Parameter IARTWRKTYP below the parameter ARTWRKTYP.
For more detail description about
How to: Change the Order of a Report Parameter (Reporting Services), please see:
http://msdn.microsoft.com/en-us/library/cc281392.aspx.
If you have any other question, please feel free to let me know.
Thanks,
Sharp Wang
Best Regards. Sharp Wang
Free Windows Admin Tool Kit Click here and download it now
June 13th, 2011 5:12am