"Sum" problems

Stimulsoft Reports.NET discussion
Post Reply
donnie
Posts: 6
Joined: Tue Mar 18, 2008 10:33 am

"Sum" problems

Post by donnie »

Hi Guys,

I'm a new with this stuff. i tried to create a report to which a dataset is binded

report.RegData(ds);

within my query i have a join between 2 tables let say goups (id, group, total...) and sub-groups (group, name, ...)

when i generate the report by grouping (group) it gives something like this

id ------- group -------- total ------- name sub-group
1 ------- 0001 -------- 20$ ------- x
1 ------- 0001 -------- 20$ ------- y
1 ------- 0001 -------- 20$ ------- z

1 ------- 0255-------- 10$ ------- a
1 ------- 0255 -------- 10$ ------- b

here's my prob. i want a subtotal of 30$ (20 + 10) but i can't do it !!!!!!!!
if i use the SUM property it gives 80$ OR depending where i put it, it gives me 2 subtotals 60$ and 20$

what can i do to solve this tiny porblem !!!
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

"Sum" problems

Post by Vital »

Hello,

Sorry, i'm not fully understand. You need calculate only first row from each group?

Thank you.
donnie
Posts: 6
Joined: Tue Mar 18, 2008 10:33 am

"Sum" problems

Post by donnie »

Vital wrote:Hello,

Sorry, i'm not fully understand. You need calculate only first row from each group?

Thank you.
I need to calculate the SUM of my "total" column. According to the example here, I need a total of 30$ (20 + 10).

the porblem with SUM, it returns the total of ALL columns (20+20+20+10+10) depending where i put it on the report !

thx
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

"Sum" problems

Post by Edward »

wrote:I need to calculate the SUM of my "total" column. According to the example here, I need a total of 30$ (20 + 10).
Unfortunately still not clear. Please send your report template (a mrt file, can be saved in Stimulsoft Reports.Net Designer) to support[at]stimulsoft.com.

We'll help you as soon as possible, it seems not a difficult question, but we need to understand the requirement first.

Thank you.
donnie
Posts: 6
Joined: Tue Mar 18, 2008 10:33 am

"Sum" problems

Post by donnie »


header
grouping (group)

id ------- group -------- total ------- name sub-group
1 ------- 0001 -------- 20$ ------- x
1 ------- 0001 -------- 20$ ------- y
1 ------- 0001 -------- 20$ ------- z

End grouping (if sum here the total = 60$ !!!!!!!!!!!!!!!!!!!!! I need 20$ as a total)

footer



header
grouping (group)

id ------- group -------- total ------- name sub-group
1 ------- 0001 -------- 20$ ------- x
1 ------- 0001 -------- 20$ ------- y
1 ------- 0001 -------- 20$ ------- z

End grouping

footer(if sum here the total = 60$ !!!!!!!!!!!!!!!!!!!!! and it's not what i want !!!! i want 20$)



header
grouping (group)

id ------- group -------- total ------- name sub-group
1 ------- 0001 -------- 20$ ------- x
1 ------- 0001 -------- 20$ ------- y
1 ------- 0001 -------- 20$ ------- z

End grouping

footer

if sum here the total = 40$ !!!!!!!!!!!!!!!!!!!!! WRONG again !!! it gives me the total of the last 2 rows
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

"Sum" problems

Post by Vital »

Please send your report template to support@stimulsoft.com.

Thank you.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

"Sum" problems

Post by Vital »

Hello!

Please create in report dictionary two variables: GroupValue and PrevID.

After then in BeginRenderEvent of GroupHeaderBand write following code:

Code: Select all

GroupValue = 0;
PrevID = -1;
After then in RenderingEvent of GroupHeaderBand write following code:

Code: Select all

if (PrevID == -1 || PrevID != MyDataSource.ID)
{
   PrevID = MyDataSource.ID;
   GroupValue += MyDataSource.Value;   
}
After then in total text component you need type:

Code: Select all

{GroupValue}
Thank you.
donnie
Posts: 6
Joined: Tue Mar 18, 2008 10:33 am

"Sum" problems

Post by donnie »

All riiight
i found a solution and i don't need a SUM property, i use Variables, pure & simple (var1 += var2)

thx anyways !
Post Reply