sum with conditon in ssrs

  • Hello all,

    I have following field in report.

    ID RespID balance Mibalance MaBalance code

    Group 1

    Group 10

    2000 1

    3000 2

    5000 3

    10000 4

    I want a output like :

    ID RespID balance Mibalance MaBalance code

    Group 1

    Group 10 20,000 2,000 18,000

    2000 1

    3000 2

    5000 3

    10000 4

    I want a output based on code

    if code=1 then Mibalance =2,000

    esle if code in(2,3,4) then 18,000(3000+5000+10000).

    How can i get Mibalance and Mabalance based on code?[/email]

  • In your second group you should be able to use the following expressions (field names may not be accurate):

    Balance:

    =SUM(Fields!Balance.Value)

    MiBalance:

    =SUM(iif(Fields!Code.Value = 1, Fields!Balance.Value, 0))

    MaBalance:

    =SUM(iif(Fields!Code.Value != 1, Fields!Balance.Value, 0))

    Basically for the Balance column the expression will sum all values.

    For the MiBalance value it will sum all values where the code = 1 (else the balance value gets replaced with 0 for the sum)

    For the MaBalance the oppostie will happen so it will sum all values where the code is not equal to 1 (and other values get replaced with 0)

    I hope that makes sense. Let us know if it works, good luck, Steve

  • Thanks Steve,

    IT's work.

    Thank you so much,,:-):-)

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

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