Choosing Column value from dataset based on Parameter

  • Hi

    Depend on the parameter value i have to choose the column value from dataset. In the textbox expression i gave

    =iif(Parameters!parameter.Value="G",Fields!Gender.Value,iif(Parameters!parameter.Value="C",Fields!rcname.Value,iif(Parameters!parameter.Value="R",Fields!Religion.Value,Fields!Age.Value)))

    which is not worked out. Is there any solution for this issue. Otherwise I have to deploy 10 reports for 10 different parameters.

    I tried code behind function

    Function GetParameterValue(ByVal parameter As String) As String

    Select Case parameter

    Case "G"

    GetParameterValue= "Fields!Gender.Value"

    Case "C"

    GetParameterValue= "Fields!rcname.Value"

    Case Else

    GetParameterValue= "Fields!Age.Value"

    End Select

    Return GetParameterValue

    End Function

    and called this function in textbox expression which is giving just string like "Fields!Gender.Value" not the value from dataset.

    Any Suggestion please.

    Thank you in advance

    Soundari

  • What error you are getting with your iif logic?

    -RP
  • Hi

    For all parameter values I am getting Gender only

    Soundari

  • Strange!!... Your logic is straight and simple. Are you sure, you have desired data in order to get other values out of this IIF function?

    -RP

    -RP
  • Hi

    Yes I having values. Still searching the solution

    Soundari

  • I don't why the IIF solution is not working, but may be you can try converting IIF into SWITCH and check if it works.

    Here is the IIF code converted into SWITCH

    =SWITCH( Parameters!parameter.Value="G", Fields!Gender.Value, Parameters!parameter.Value="C", Fields!rcname.Value, Parameters!parameter.Value="R", Fields!Religion.Value, TRUE, Fields!Age.Value )

    --Ramesh


  • Hi

    I tried with Switch. Not displaying any value. Now I added n columns for n parameters. For each Column visibility property I set the expression like

    =iif(Parameters!parameter.Value="G",False,True)

    Now I got my result. But still I dont Know why iif and Switch function didnt worked out

    Thank You

    Soundari

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply