How to SubTotal with top N grouping?

Hi all,

I have a table on my report with a group on a field. I just want to SubTotal the 5 rows per group! I can get a sum per group,however, this sum is for all the rows per group! I just need the total for the first 5 rows per group! Can anybody help me with this Thanks.

Group #1
2
3
4
0
2
1
========
Sub-Total:11 (Sub-Total for the first 5 rows)
========
Group #2
1
2
0
2
2
10
8
========
Sub-Total:7 (Sub-Total for the first 5 rows)
========


Answer this question

How to SubTotal with top N grouping?

  • yuval08

    I am also trying to do a very similar thing with displaying on the Top 10 of my group and I want my totals only to show the Top 10. You mentioned a "sub group", maybe I'm misunderstanding, but how do you make a sub group Are you just talking about another group with a similar expression I've tried that and Im having a very hard time getting just the totals of the Top 10 at the bottom.
  • Kevin F

    damn it i keep reading it wrong. what you need is to have a sub group under your existing group grouping everything top 5. then at the footer for your original group you add subtotal for the sub group. like in my last post.

  • Chris Conner

    I think what you need here is something like this

    Page Breaks

    In some reports, you may want to place a page break at the end of a specified number of rows instead of, or in addition to, on groups or report items. To do this, create a group in a data region (typically a group immediately outside the detail), add a page break to the group, and then add a group expression to group by a specified number of rows.

    • The following expression, when placed in the group expression, assigns a number to each set of 25 rows. When a page break is defined for the group, this results in a page break every 25 rows.
      =Int((RowNumber(Nothing)-1)/25)

    <<Direct from reporting services online help.>>

    I think you group by every five rows. and then aggrigate.
    I can't exactly say how this is supposed to work. But if you fiddle with it you might be able to do it.

  • RSX-S

    this is already answered in my post above. it is simple really, you have your existing group.
    you add another group under that group to hold together the top 10 this is called a sub group.
    you name this group "top10" or something like that.
    then you add =Sum(Fields!Total.Value, "top10") where you want the subtotal of the top ten.

  • Richie_C

    This is exactly what I do from my group footer, but i cannot access to the total of my subGroup.

    May be I didn't understand. How can you do that


  • John_S

    Hi,

    Does anybody able to solve this, if so can you please explain how we can do that.

    Thanks



  • Lucian Bargaoanu

    Note that the second (inner) group expression must group on something that is unique within the first (outer) group. Otherwise the TopN filter on the inner group (using a filter expression identical to the inner grouping expression) would not filter the top 5.
    In order to achieve a unique grouping per row for the inner group, you may need to combine the values of multiple fields. One way of ensuring uniqueness of smashed keys is to add a delimiter that is not one of the characters used in the two fields (e.g. "|" or some Unicode character), e.g. =CStr(Fields!A.Value) & "|" & CStr(Fields!B.Value)

    -- Robert
     

  • Jules Noda

    sorry bro, think i misread your question. I think this is what you want.
    if i read your question correctly (this time Wink),

    Sum(Fields!Total.Value, "GroupByFive")

    Where "GroupByFive" is name of the group that does the grouping of 5 rows.
    This will give you the sub totals of each "GroupByFive" group.

  • How to SubTotal with top N grouping?