Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check multiple conditions in rdlc expression

I have worked on only possible 2 in rdlc Expression values as like

=iif((Fields!Gender.Value="1"),"Male","Female")

Here I can work with only 2 possibilities. But if I want to check 3 or more conditions than how can I?

like image 716
Sonam Mohite Avatar asked Jul 25 '12 11:07

Sonam Mohite


3 Answers

Use the Switch if you have more conditions, it is also more readable.

=Switch(
    Fields!Gender.Value = 1, "Male", 
    Fields!Gender.Value = 2, "Female"
    )

rdlc expression iif use?

like image 188
Muhammad Omar ElShourbagy Avatar answered Oct 08 '22 10:10

Muhammad Omar ElShourbagy


You can use the Code property of the report. Right-click a blank space outside your report and click Report Properties or click the Report menu and click report properties.

Click the "Code" tab and type your condition checking statement as below

Public Function GetGender(ByVal val as String) As String
   Dim retVal as String = ""

   If(val = "1")
    retVal = "Male"
   Else If (val = "2")
    retVal = "???"
   Else If (val = "3")
    retVal = "???"
   Else
    retVal = "???"
   End If

   Return retVal

End Function

Then call the function in the expression of your textbox

= Code.GetGender(Fields!Gender.Value)
like image 25
codingbiz Avatar answered Oct 08 '22 11:10

codingbiz


try this one :

=iif(Fields!Gender.Value="1","Male", iif(Fields!Gender.Value="2","Female","Undefined"))

the format is :

=iif(expression=value, true, false)

you can change with :

=iif(expression=value, true, iif(expression2=value2, true, false))
like image 34
Asromi rOmi Avatar answered Oct 08 '22 09:10

Asromi rOmi