IIf statement

  • I have requirements where I need to convert business objects report in SSRS, I canโ€™t able to work the below statement "if" statement in SSRS. Thanks for your help in advance.

    Business Objects

    =If [Position Type]="Held" Then "Margin Posted to PRINCIPAL" Else If [Position Type]="Posted" Then "Margin Posted to COUNTERPARTY" Else If [Receiving Party]= "Counterparty" And [Position Type] ="Deliver" Or [Receiving Party] ="Principal" And [Position Type] = "Return" Then "Margin Posted to PRINCIPAL" Else If [Receiving Party]= "Principal" And [Position Type] = "Deliver" Or [Receiving Party] = "Counterparty" And [Position Type] = "Return" Then "Margin Posted to COUNTERPARTY"

    SSRS

    =IIf(Fields!PositionType.Value="Held","Margin Posted to PRINCIPAL",IIf(Fields!PositionType.Value="Posted","Margin Posted to COUNTERPARTY",IIf(Fields!RECEIVINGPARTY.Value="Principal","Margin Posted to PRINCIPAL",IIf(Fields!RECEIVINGPARTY.Value="Counterparty","Margin Posted to COUNTERPARTY","Margin Posted to COUNTERPARTY"))))

  • You might find using a SWITCH statement is easier. A switch is a boolean condition followed by what happens if it is true, then another boolean etc.

    =SWITCH(Fields!PositionType.Value="Held","Margin Posted to PRINCIPAL",Fields!PositionType.Value="Posted","Margin Posted to COUNTERPARTY",Fields!RECEIVINGPARTY.Value="Principal","Margin Posted to PRINCIPAL",Fields!RECEIVINGPARTY.Value="Counterparty","Margin Posted to COUNTERPARTY",1=1,"Margin Posted to COUNTERPARTY")

    The 1=1 is acting as an ELSE for when none of the previous conditions are met.

  • Refere below one

    http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/6b09643c-1bc6-4ffb-9194-13044e1752e5

    Thanks & Regards,
    Veeren.
    Ignore this if you feel i am Wrong. ๐Ÿ˜‰

  • Thanks for everyone reply, when i am using the above "Switch" statement i am not getting an correct data. Can you guys please let me know how can i resolve this in SSRS?

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

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