Wednesday, March 28, 2012

how to get the sum of a group and not the whole column?

?can you explain further? any sample data with desired output will help|||

example:

Account Sales

New

John Doe 1,000,000

George Bush 2,000,000

Juan Luna 3,000,000

6,000,000

Old

Michael Tell 5,000,000

Billy Banks 2,000,000

7,000,000

where Account and Sales are table columns, New and Old are group names.

i want to display the total of the group.

|||anyone? something like a GroupSum() function.|||i have no Reporting services installed on my system but in Crystal Reports, you can do this by creating a Running Total field...|||

You can do this by using a matrix, and put two row groups on it: the first grouping by account age (new/old), the second by name.

Or you can put them in a list control and apply a group to the list, and sum the sales inside the list.

sluggy

|||there's a runningValue function but I'm getting exceptions when I use it. I just want to display the subtotal not the Total of the sales column.|||

CryptoKnight wrote:

i have no Reporting services installed on my system but in Crystal Reports, you can do this by creating a Running Total field...

Account Sales

New

John Doe 1,000,000

George Bush 2,000,000

Juan Luna 3,000,000

6,000,000

Old

Michael Tell 5,000,000

Billy Banks 2,000,000

13,000,000

this is the output when I use the running value.

|||

icemart525 wrote:

there's a runningValue function but I'm getting exceptions when I use it. I just want to display the subtotal not the Total of the sales column.


is there a reset on change of group property? try setting it to reset after every change of group if there's one...|||nope I can't find one.|||I've seen a lot of topics about subtotals in the web but they did not mention how to do it. should I add a new dataset for this?|||

icemart525 wrote:

I've seen a lot of topics about subtotals in the web but they did not mention how to do it. should I add a new dataset for this?

You are confusing me.... i gave you the answer how to do this several replies ago, did you not see it?

And to answer the other question: if you apply a group expression to a container, then any aggregation type functions (sum, avg, etc.) are done within the scope of only that group.

sluggy

|||I'm using a table, my total returns the Total of the column and not the group. I have not tried a list or a matrix though.|||

icemart525 wrote:

I'm using a table, my total returns the Total of the column and not the group. I have not tried a list or a matrix though.

Okay, for this scenario just put your table inside a list, and apply the group expression to the list. The list (with its table) then gets (automatically) repeated for every group there is, and the table will only "see" data that is in that group. Hope that helps

sluggy

|||okay i'll try your solution later, i'll let you know the results as soon as i get it.

No comments:

Post a Comment