String Comparison in Expression

  • Hi,

    I have the following peice of code that has been working well for me for a long time. You will see below that  (Not Submitted) is appended to the Description.Value based on the IIF statement. It works great!

    =IIF( Fields!Date_Received.Value < "01/01/00" AND Fields!Exam_Date.Value > "01/01/00" AND   NOW() > DATEADD("d",8,Fields!Date.Value) AND Fields!Mark.Value = -1, Fields!Description.Value  & "  (Not submitted)", IIf( Fields!Absent.Value  = 1 , Fields!Description.Value & "     (Absent)", Fields!Description.Value ) )

    However, a requirement has now arisen that the (Not Submitted) only be appended to the Description.Value if the Description.Value does not contain the word 'Real'....I attempted the code below so far by adding to the beginning of the IIF statement..

    =IIF(Fields!Description.Value NOT LIKE "*Real*"  AND Fields!Date_Received.Value < "01/01/00" AND Fields!Exam_Date.Value > "01/01/00" AND   NOW() > DATEADD("d",8,Fields!Date.Value) AND Fields!Mark.Value = -1, Fields!Description.Value  & "  (Not submitted)", IIf( Fields!Absent.Value  = 1 , Fields!Description.Value & "     (Absent)", Fields!Description.Value ) )

    =IIF(Fields!Description.Value <> "*Real*"  AND Fields!Date_Received.Value < "01/01/00" AND Fields!Exam_Date.Value > "01/01/00" AND   NOW() > DATEADD("d",8,Fields!Date.Value) AND Fields!Mark.Value = -1, Fields!Description.Value  & "  (Not submitted)", IIf( Fields!Absent.Value  = 1 , Fields!Description.Value & "     (Absent)", Fields!Description.Value ) )

    =IIF( Fields!Date_Received.Value < "01/01/00"

    AND Fields!Exam_Date.Value > "01/01/00"

    AND NOW() > DATEADD("d",8,Fields!Exam_Date.Value)

    AND Fields!Mark.Value = -1 AND

    Fields!Exam_Description.Value LIKE "*Test*", Fields!Exam_Description.Value & " (Not Submitted)",

    IIF(Fields!Exam_Description.Value LIKE "*Mock*", Fields!Exam_Description.Value & " (Not Submitted)",

    IIF(Fields!Exam_Description.Value LIKE "*Quiz*", Fields!Exam_Description.Value & " (Not Submitted)",

    IIF(Fields!Exam_Description.Value LIKE "*Case*", Fields!Exam_Description.Value & " (Not Submitted)",

    IIF(Fields!Exam_Description.Value LIKE "*Intro*", Fields!Exam_Description.Value & " (Not Submitted)",

    IIF(Fields!Exam_Description.Value LIKE "*Course*", Fields!Exam_Description.Value & " (Not Submitted)",  

    IIF(Fields!Exam_Description.Value LIKE "*Real*", Fields!Exam_Description.Value ,

    IIf( Fields!Absent.Value  = 1 , Fields!Exam_Description.Value & "     (Absent)", Fields!Exam_Description.Value))))))))

    My results are currently comming back with the " (Not Submitted)" appended to everything (except 'Real') regardless of whether it meets the other criteria ie the mark.value and date values....

    Any help would be greatly appreciated.

     

    Thanks

  • What if you rephrase this code so that it begins

    =Fields!Exam_Description.Value & IIF(.... ?

    also, is there any way of using a CASE statement instead of IIF?

    also, what version are you writing in? the version may be material here.

  • Thanks for your reply. In the end I managed to do it like this;

    =IIF(Fields!Exam_Description.Value

    LIKE "*Real*"

    AND

    Fields!Date_Received.Value < "01/01/00"

    AND

    Fields!Exam_Date.Value > "01/01/00"

    AND

    NOW() > DATEADD("d",8,Fields!Exam_Date.Value)

    AND

    Fields!Mark.Value = -1, Fields!Exam_Description.Value,

    IIF(Fields!Exam_Description.Value

    LIKE "**"

    AND

    Fields!Date_Received.Value < "01/01/00"

    AND

    Fields!Exam_Date.Value > "01/01/00"

    AND

    NOW() > DATEADD("d",8,Fields!Exam_Date.Value)

    AND

    Fields!Mark.Value = -1, Fields!Exam_Description.Value & " (Not Submitted)", Fields!Exam_Description.Value))

Viewing 3 posts - 1 through 2 (of 2 total)

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