Skip to Content
avatar image
Former Member

If/Else/Then statement in Bex

Hi all,

I want to create some conditional logic in Bex formula. The logic I need is:

IF (KeyFigA exists) THEN (use KeyFigA) ELSE IF (KeyFigB exists) THEN (use KeyFigB) ELSE (use KeyFigC)

I am a bit confused on the operators I need to use...Can anyone help?

Thanks

CM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 20, 2008 at 09:02 PM

    Courtney,

    It depends on what you mean by "EXISTS" here. If it means that the value is <> 0, then the logic would be:

    ( KFA .NE. 0 ) * KFA + (KFA == 0 ) * (KFB .NE. 0 ) * KFB + ( KFA == 0 ) * ( KFB == 0 ) * KFC

    Note: ".NE." above will actually be a < followed by >, but this silly editor doesn't like those characters.

    Hope this helps...

    Bob

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      ( KFA <> 0 ) * KFA + (KFA == 0 ) * (KFB <> 0 ) * KFB + ( KFA == 0 ) * ( KFB == 0 ) * KFC

      Just as Bob said, however, you need to use the <> symbols for .NE.. You can also select the symbols in the Boolean Logic section.

      Brian

      I think I know why Bob added the .NE., even though I can see them in my edit screen, they are not showing up in the message after I save it.

      Edited by: Brian Anthony on Oct 20, 2008 4:39 PM

  • avatar image
    Former Member
    Oct 22, 2008 at 12:59 PM

    This works perfectly. Thank you!

    Add comment
    10|10000 characters needed characters exceeded