9
=IIf(Fields!TarifeTipiNo.Value = 265, "Saturday", IIf(Fields!TarifeTipiNo.Value = 266, "Monday", IIf(Fields!TarifeTipiNo.Value = 267, "Wednesday")))

I am trying to write expression into a cell in my report [rdlc file] but I just couldn't achieve this. If the cell is equal to 265 then Saturday should display or if it is equals to 266 then "Monday" should show up. Can someone help me out with it please?

shahkalpesh
  • 33,172
  • 3
  • 63
  • 88
Cute Bear
  • 3,223
  • 13
  • 44
  • 69
  • 1
    This looks like SSRS, not ASP.NET. – jrummell Mar 12 '12 at 12:22
  • What is currently displaying? – scott.korin Mar 12 '12 at 12:23
  • @scott.korin, I just get exception saying Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred while compiling expressions. Native compiler return value: ‘[BC40000] 'RequestMinimum' is obsolete: 'Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.'.’. – Cute Bear Mar 12 '12 at 12:27
  • 1
    For people who got here by google... the solution to the RequestMinimum exception is here: http://stackoverflow.com/questions/8244098/rdlc-making-call-to-obsolete-securityaction-enumeration – MatthewMartin Nov 06 '12 at 19:34

3 Answers3

20

The last IIF in the example code has true part specified. However, the false part isn't specified.

=IIf(Fields!TarifeTipiNo.Value = 265, "Saturday", IIf(Fields!TarifeTipiNo.Value = 266, "Monday", IIf(Fields!TarifeTipiNo.Value = 267, "Wednesday", "????")))

OR

=Switch(Fields!TarifeTipiNo.Value = 265, "Saturday", Fields!TarifeTipiNo.Value = 266, "Monday", Fields!TarifeTipiNo.Value = 267, "Wednesday")

shahkalpesh
  • 33,172
  • 3
  • 63
  • 88
  • 2
    +1 to shahkalpesh's Switch statement - or alternatively call custom code and use a select. Those IIfs are pains to write, not to mention maintain when you make a change in more than a couple of cells. – thomasswilliams Mar 13 '12 at 00:40
2

Just to complete the set of available program flow options in SSRS expressions, with sequential values you can also use Choose:

=Choose(Fields!TarifeTipiNo.Value-264, "Saturday", "Monday", "Wednesday")
-2
=First(Fields!Shipping_Name.Value, "DataSetForOrderEntry")+environment.NewLine+iif((First(Fields!Shipping_Company.Value, "DataSetForOrderEntry")=""),"",First(Fields!Shipping_Company.Value, "DataSetForOrderEntry")+environment.NewLine)+First(Fields!Shipping_Address1.Value, "DataSetForOrderEntry")+environment.NewLine+First(Fields!Shipping_Address2.Value, "DataSetForOrderEntry")+environment.NewLine+First(Fields!Shipping_City.Value, "DataSetForOrderEntry")+","+First(Fields!Shipping_State.Value, "DataSetForOrderEntry")+" "+First(Fields!Shipping_Zip.Value, "DataSetForOrderEntry")
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • 2
    Welcome to Stack Overflow! While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – Ajean Mar 15 '16 at 02:14