If A Not Equal to B in SSRS

21,937

Solution 1

The <> may not work if your values contain NULL so you may have to run a multiple case comparison such as:

IiF(A<>B OR A IsNothing OR B IsNothing, "C", "D")

Solution 2

This Code will work for you :

=IIF(Not A = B,"D","C")
Share:
21,937
UpwardD
Author by

UpwardD

Updated on June 13, 2020

Comments

  • UpwardD
    UpwardD almost 4 years

    I understand IIF very well but I am trying to write an expression like the below in SSRS.

        IF A<>B,"D"
        =IIF(A <> B,"C","D") -- this doesn't work for me 
    

    What replaces the sign, "<>" in the expression?

    • JC Ford
      JC Ford almost 9 years
      <> is the "not equal" comparison operator in VB (the language of SSRS expressions) Can you elaborate on what you're trying to do that isn't working?
  • JC Ford
    JC Ford almost 9 years
    This isn't true in the VB.NET world. Nothing gets converted to whatever type it's being compared to, so Nothing = "" would evaluate to True as would Nothing = Nothing.
  • SQLHound
    SQLHound almost 9 years
    And I agree with you completely, but SSRS sometimes plays by its own rules (this assessment based on experience and not documented instances).