VB code for total

  • Hi, I have following matrix in my report.

    Everything is okay except final total

    MAtrix ! C1 - C2 - C3 - C4 - C5

    ----------------------------------------------------

    11/2/2011 ! 1 - 4 - 7 - 10 - (1- (1+4+7))/10

    11/3/2011 ! 2 - 5 - 8 - 11 - (1- (2+5+8))/11

    11/4/2011 ! 3 - 6 - 9 - 12 - (1- (3+6+9))/12

    ----------------------------------------------------

    TOTAL ! 6 - 15 - 24 - 33 - (1- (6+15+24))/33

    ------------------------------------------------------------------------

    All the columns add up fine but I also get C5 added up while it should be calculated like like above.

    How can I achieve C5 total as above. I think I may have to write a vb code, but not sure

    thanks.

  • = (1 - SUM(C1 + C2 + C3)) / SUM(C5)

    Put an IIF to avoir divide by 0 error.

  • all C1 c2 c3 cr c5 columns come from one single column in my stored proc.

    I have not been able to put the way you mentioned in SSRS.

  • What's the exact code you used?

    The error you get?

    Or the wrong results vs the correct results?

  • Ninja's_RGR'us (11/17/2011)


    What's the exact code you used?

    The error you get?

    Or the wrong results vs the correct results?

    MAtrix ! C1 - C2 - C3 - C4 - C5

    ----------------------------------------------------

    11/2/2011 ! 1 - 4 - 7 - 10 - (-2/10)

    11/3/2011 ! 2 - 5 - 8 - 11 - (-4/11)

    11/4/2011 ! 3 - 6 - 9 - 12 - (-6/12)

    ----------------------------------------------------

    TOTAL ! 6 - 15 - 24 - 33 - (-12/33)

    I can not get this (-12/33) part instead I get (-2,10, -4/11, -6/12) added up in C5 final total....

  • What code did you use?

  • I am using the same formula , you mentioned, to get all C5 values in my proc, so that I dont have to do any calculations in SSRS.

    and I only do subtotal at the end of matrix to add up everything.

    So everythings addup , but in turn C5 values also get added up while I want it to be calculated based on other field totals.

    basically is it possible to calculate one column total diffferently than other columns in the same matrix. (c1,c2,c3, c4 should add up in a simple way , but C5 final total should be caluculated based on totals of C1,c2,c3,c4) .

  • Yes it's possible.

    Can't help you without seeing your code.

  • Thanks, I hope I could do that, but the company policies do not allow me.

  • SQL_Nw (11/17/2011)


    Thanks, I hope I could do that, but the company policies do not allow me.

    I only need the code you have in that textbox for SSRS. Nothing else.

    It's not like I can rebuild the formula to spit the atom with that.

    Non-edit (funnier with that typo :-D).

  • Thanks.

    =iif(Fields!ID.Value =5,

    max(Fields!freq.Value), sum(Fields!freq.Value))

    This is in the data cell of matrix

    1,2,3,4 IDs are for c1,c2,c3,c4

    C5 has Id =5

  • I don't understand why you need to do that. Can you explain more what you're doing?

  • Finally I managed to do it. I had to modify my stored proc and used Inscope function in ssrs.

    Greatly appreciate your willingness to help. I just couldn't explain whole scenario. its kind of spaggetti ..Thank you.

  • Happy to help!

Viewing 14 posts - 1 through 13 (of 13 total)

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