Search code examples
reporting-servicesssrs-2017

SSRS Textbox expression modifying


i designed a tablix report, i have a text box called Student-Attendance which dispaly the information below.

 Student_Attendance

   Sick 
  Absence
  Present

I have tried to use IIF statement in order to show it as S,A,P. Other than "IIF" is there anything i could use in order to get my result.

IIF (Fields!Student_Attendance.value = "Sick", "S" ) and IIF(Fields!Student_Attendance.value = "Absence" , "A")


Solution

  • IIF Takes 3 arguments

    1. The condition (if field = value)
    2. What to return if true (e.g. "S")
    3. What to return if false - you are missing this

    If you want to use IIF then you have to nest the IIFs

    =IIF(Fields!Student_Attendance.value = "Sick", "S", IIF(Fields!Student_Attendance.value = "Absence" , "A") )
    

    What might be simpler is SWITCH especially if you have more than a few options, something like this

    =SWITCH (
    Fields!Student_Attendance.value = "Sick", "S",
    Fields!Student_Attendance.value = "Absence", "A",
    Fields!Student_Attendance.value = "Present", "P"
    )