n_srikanth4
asked on
Report Expression using SWITCH
Hi Experts,
Please find the report expression mentioned here under . I believe that there is a syntax error . Please correct my code . It is working , only for the first case.It is not working for the other 3 cases. Please let me know if i can use the IIF statement for this report expression.
=SWITCH(
(Parameters!Inv_Type_Code. Value = "CAZ" AND Fields!IS_AQGT73200.Value =1) , First(Fields!LDZ_IDENTIFIE R.Value, "SV_Exception_Report"),
(Parameters!Inv_Type_Code. Value = "CAZ" AND Fields!IS_AQGT73200.Value =0) ,First(Fields!LCH_LDZ_IDEN TIFIER.Val ue, "SV_Exception_Report"),
(Parameters!Inv_Type_Code. Value = "COM" AND Fields!IS_AQGT73200.Value =1) , First(Fields!LDZ_IDENTIFIE R.Value, "SV_Exception_Report"),
(Parameters!Inv_Type_Code. Value = "COM" AND Fields!IS_AQGT73200.Value =0) ,First(Fields!LCH_LDZ_IDEN TIFIER.Val ue, "SV_Exception_Report")
)
Regards,
Sreekanth.
Please find the report expression mentioned here under . I believe that there is a syntax error . Please correct my code . It is working , only for the first case.It is not working for the other 3 cases. Please let me know if i can use the IIF statement for this report expression.
=SWITCH(
(Parameters!Inv_Type_Code.
(Parameters!Inv_Type_Code.
(Parameters!Inv_Type_Code.
(Parameters!Inv_Type_Code.
)
Regards,
Sreekanth.
Have you tried taking out the parenthesis... like this?
=SWITCH(Parameters!Inv_Typ e_Code.Val ue = "CAZ" AND Fields!IS_AQGT73200.Value =1 , First(Fields!LDZ_IDENTIFIE R.Value, "SV_Exception_Report"),
Parameters!Inv_Type_Code.V alue = "CAZ" AND Fields!IS_AQGT73200.Value =0),First(Fields!LCH_LDZ_I DENTIFIER. Value, "SV_Exception_Report"),
Parameters!Inv_Type_Code.V alue = "COM" AND Fields!IS_AQGT73200.Value =1 , First(Fields!LDZ_IDENTIFIE R.Value, "SV_Exception_Report"),
Parameters!Inv_Type_Code.V alue = "COM" AND Fields!IS_AQGT73200.Value =0 ,First(Fields!LCH_LDZ_IDEN TIFIER.Val ue, "SV_Exception_Report")
)
=SWITCH(Parameters!Inv_Typ
Parameters!Inv_Type_Code.V
Parameters!Inv_Type_Code.V
Parameters!Inv_Type_Code.V
)
ASKER
I will explain what eactly i require then you can correct my expression mentioned in the comment above.
IF (Parameters!Inv_Type_Code. Value = "CAZ" AND Fields!IS_AQGT73200.Value =1 ) THEN
Fields!LDZ_IDENTIFIER.Valu e
ELSE IF (Parameters!Inv_Type_Code. Value = "CAZ" AND Fields!IS_AQGT73200.Value =0 ) THEN
Fields!LCH_LDZ_IDENTIFIER. Value
ELSE IF (Parameters!Inv_Type_Code. Value = "COM" AND Fields!IS_AQGT73200.Value =1 ) THEN
Fields!LDZ_IDENTIFIER.Valu e
ELSE IF (Parameters!Inv_Type_Code. Value = "COM" AND Fields!IS_AQGT73200.Value =0 ) THEN
Fields!LCH_LDZ_IDENTIFIER. Value
Your comments are greatly appreciated.
Regards,
Sreekanth.
IF (Parameters!Inv_Type_Code.
Fields!LDZ_IDENTIFIER.Valu
ELSE IF (Parameters!Inv_Type_Code.
Fields!LCH_LDZ_IDENTIFIER.
ELSE IF (Parameters!Inv_Type_Code.
Fields!LDZ_IDENTIFIER.Valu
ELSE IF (Parameters!Inv_Type_Code.
Fields!LCH_LDZ_IDENTIFIER.
Your comments are greatly appreciated.
Regards,
Sreekanth.
Hi,
Try conditions 1 by 1. Dont type the entire expression at once.
You said that first condition is met and displaying the result. So, try with second condition.
If so, try with first and second.
Then you can figureout the problem
Try conditions 1 by 1. Dont type the entire expression at once.
You said that first condition is met and displaying the result. So, try with second condition.
If so, try with first and second.
Then you can figureout the problem
ASKER
Hi rajvja,
The switch case is not working. i don't know how to implement multiple conditions using IIF.
Can you put the above mentioned functionality in to an IIF Statement and send me the Expression please.
Regards,
Sreekanth.
The switch case is not working. i don't know how to implement multiple conditions using IIF.
Can you put the above mentioned functionality in to an IIF Statement and send me the Expression please.
Regards,
Sreekanth.
Hi,
It will work. I dont know why you are not getting. Or else try this way
Write code which return the value based on the parameters
public function GetResult(ByVal InvTypeCode as string, ByVal AQGTVal as String) as String
dim retVal as string
write your if condition
RETURN retVal
end function
From the expression, instead of switch,
=Code!GetResult(Parameters !Inv_Type_ Code.Value ,Fields!IS _AQGT73200 .Value)
It will work. I dont know why you are not getting. Or else try this way
Write code which return the value based on the parameters
public function GetResult(ByVal InvTypeCode as string, ByVal AQGTVal as String) as String
dim retVal as string
write your if condition
RETURN retVal
end function
From the expression, instead of switch,
=Code!GetResult(Parameters
That's exactly what I was going to suggest next. Looks like rajvja has your answer.
ASKER
Rajvja,
I have used the function mentioned here under in the report expression as per your guidelines using the code property. But it is no good and will not work . Please correct my custom code and send me the solution. Please check the parameters i have passed, one is string and other is decimal.
Public shared function GetResult(ByVal Inv_Type_Code as string, ByVal IS_AQGT73200 as Decimal) as String
Dim LDZ_IDENTIFIER as string
Dim LCH_LDZ_IDENTIFIER as string
IF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 = 1) THEN
RETURN LDZ_IDENTIFIER
ELSE IF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 =0) THEN
RETURN LCH_LDZ_IDENTIFIER
ELSE IF(Inv_Type_Code = "COM" AND IS_AQGT73200 =1)THEN
RETURN LDZ_IDENTIFIER
ELSE IF(Inv_Type_Code = "COM" AND IS_AQGT73200 =0) THEN
RETURN LCH_LDZ_IDENTIFIER
END IF
End Function
Using this code in the Report Expression:
Code.GetResult(Parameters! Inv_Type_C ode.Value, Fields!IS_ AQGT73200. Value)
Regards,
Sreekanth.
I have used the function mentioned here under in the report expression as per your guidelines using the code property. But it is no good and will not work . Please correct my custom code and send me the solution. Please check the parameters i have passed, one is string and other is decimal.
Public shared function GetResult(ByVal Inv_Type_Code as string, ByVal IS_AQGT73200 as Decimal) as String
Dim LDZ_IDENTIFIER as string
Dim LCH_LDZ_IDENTIFIER as string
IF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 = 1) THEN
RETURN LDZ_IDENTIFIER
ELSE IF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 =0) THEN
RETURN LCH_LDZ_IDENTIFIER
ELSE IF(Inv_Type_Code = "COM" AND IS_AQGT73200 =1)THEN
RETURN LDZ_IDENTIFIER
ELSE IF(Inv_Type_Code = "COM" AND IS_AQGT73200 =0) THEN
RETURN LCH_LDZ_IDENTIFIER
END IF
End Function
Using this code in the Report Expression:
Code.GetResult(Parameters!
Regards,
Sreekanth.
Hi
Where are you assigning the value(return value)
Public shared function GetResult(ByVal Inv_Type_Code as string, ByVal IS_AQGT73200 as Decimal) as String
Dim retVal as string
IF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 = 1) THEN
retVal = "LDZ"
ELSE IF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 =0) THEN
retVal="LCHLDZ"
ELSE IF(Inv_Type_Code = "COM" AND IS_AQGT73200 =1)THEN
retVal="LDZ"
ELSE IF(Inv_Type_Code = "COM" AND IS_AQGT73200 =0) THEN
retVal="LCHLDZ"
END IF
End Function
expression
=IIF(Code.GetResult(Parame ters!Inv_T ype_Code.V alue,Field s!IS_AQGT7 3200.Value )="LDZ",Fi elds!LDZ_I DENTIFIER. Value,Fiel ds!LCH_LDZ _IDENTIFIE R.Value)
Hope this works
Where are you assigning the value(return value)
Public shared function GetResult(ByVal Inv_Type_Code as string, ByVal IS_AQGT73200 as Decimal) as String
Dim retVal as string
IF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 = 1) THEN
retVal = "LDZ"
ELSE IF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 =0) THEN
retVal="LCHLDZ"
ELSE IF(Inv_Type_Code = "COM" AND IS_AQGT73200 =1)THEN
retVal="LDZ"
ELSE IF(Inv_Type_Code = "COM" AND IS_AQGT73200 =0) THEN
retVal="LCHLDZ"
END IF
End Function
expression
=IIF(Code.GetResult(Parame
Hope this works
Hi,
I forgot the RETURN retVal at the end of the function i.e before End Function
I forgot the RETURN retVal at the end of the function i.e before End Function
ASKER
Rajvja,
I have implemented exactly what you have mentioned above putting the retval before the End Function. I won't work. I took that off an tried, still won't return me what I am expecting . Is there any way , i can implement using the switch case.
Regards,
Sreekanth.
I have implemented exactly what you have mentioned above putting the retval before the End Function. I won't work. I took that off an tried, still won't return me what I am expecting . Is there any way , i can implement using the switch case.
Regards,
Sreekanth.
Try this for your function:
Public Shared Function GetResult(ByVal Inv_Type_Code as String, ByVal IS_AQGT73200 as Decimal) as String
Dim retVal as string
IF (Inv_Type_Code = "CAZ" AND IS_AQGT73200 = 1) THEN
retVal = "LDZ"
ELSEIF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 =0) THEN
retVal="LCHLDZ"
ELSEIF(Inv_Type_Code = "COM" AND IS_AQGT73200 =1) THEN
retVal="LDZ"
ELSEIF(Inv_Type_Code = "COM" AND IS_AQGT73200 =0) THEN
retVal="LCHLDZ"
END IF
Return retVal
End Function
Also, since SSRS doesn't provide any troubleshoot mechanisms as the VS IDE does, I usually write and test the functions I use in SSRS in a test application first to make sure they work before copying them to the report.
And now that I actually look at your logic... why are you even testing the parameter Inv_Type_Code if you're returning LDZ or LCHLDZ based the value of IS_AQGT73200 being 1 or 0? What not just test for IS_AQGT73200 as follows... unless I'm missing something?
Public Shared Function GetResult(ByVal Inv_Type_Code as String, ByVal IS_AQGT73200 as Decimal) as String
Dim retVal as string
IF (Inv_Type_Code = "CAZ" AND IS_AQGT73200 = 1) THEN
retVal = "LDZ"
ELSEIF(Inv_Type_Code = "CAZ" AND IS_AQGT73200 =0) THEN
retVal="LCHLDZ"
ELSEIF(Inv_Type_Code = "COM" AND IS_AQGT73200 =1) THEN
retVal="LDZ"
ELSEIF(Inv_Type_Code = "COM" AND IS_AQGT73200 =0) THEN
retVal="LCHLDZ"
END IF
Return retVal
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
TMarkham1:
Thanks for the immediate reply in the first place. You mean to say that I have to write the above mentioned two functions in the custom code .
in the data base , actually IS_AQGT73200 is a bit which either returns 1 or 0 , is it ok to declare this parameter as decimal or do i have to declare it as a bit.
Regards,
Sreekanth.
Thanks for the immediate reply in the first place. You mean to say that I have to write the above mentioned two functions in the custom code .
in the data base , actually IS_AQGT73200 is a bit which either returns 1 or 0 , is it ok to declare this parameter as decimal or do i have to declare it as a bit.
Regards,
Sreekanth.
ASKER
TMarkham1,
HOW TO USE THE ABOVE TWO FUNCTIONS IN THE REPORT EXPRESSION ??
Regards,
Sreekanth.
HOW TO USE THE ABOVE TWO FUNCTIONS IN THE REPORT EXPRESSION ??
Regards,
Sreekanth.
First of all, you might over-thinking this whole task. I feel like I might be telling you to build a Boeing 787 when all you may really need is a bicycle. I don't know... you'll have to make that decision yourself.
Anyhow, the function itself isn't written in the expression area... you call the function using the expression. The actually function gets created in the "Code" page of the Report Properties dialog box. You can access the Report Properties from the Report menu. See these links for more info:
http://msdn.microsoft.com/en-us/library/ms155798.aspx
http://odetocode.com/articles/130.aspx
http://bryantlikes.com/articles/824.aspx
Anyhow, the function itself isn't written in the expression area... you call the function using the expression. The actually function gets created in the "Code" page of the Report Properties dialog box. You can access the Report Properties from the Report menu. See these links for more info:
http://msdn.microsoft.com/en-us/library/ms155798.aspx
http://odetocode.com/articles/130.aspx
http://bryantlikes.com/articles/824.aspx
ASKER
Excellent
Is there any data that satisfies the conditions 2 to 3?