avg in two subreport

Stimulsoft Reports.NET discussion
majidsoft
Posts: 66
Joined: Fri May 07, 2010 6:54 am

avg in two subreport

Post by majidsoft »

hi i have two subreport in my report i have one field in each of them
when i want to get avg of that to field in my main report i face a problem which code i must use to get avg of them
thanks
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

avg in two subreport

Post by Jan »

Hello,

Can you provide more details about your question?

Thank you.
majidsoft
Posts: 66
Joined: Fri May 07, 2010 6:54 am

avg in two subreport

Post by majidsoft »

hi
i have on text box (text box3) in sub report1 and another (text box 4) in sub report2 now i have a field in my main report (text box 1) now i want to get avg from text box3 , text box4 in text box1
i write {avg(textbox1),(textbox2)} but not work
thanks
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

avg in two subreport

Post by Ivan »

Hello,

If your textbox3 contain {expression1} and textbox4 contain {expression2}, then please write the following expression in the textbox1:

Code: Select all

{(expression1 + expression2) / 2m}
Thank you.
Attachments
521.Report sample.mrt
(8.05 KiB) Downloaded 344 times
majidsoft
Posts: 66
Joined: Fri May 07, 2010 6:54 am

avg in two subreport

Post by majidsoft »

HI
but if one of my field have null value is avg working good
thanks
majidsoft
Posts: 66
Joined: Fri May 07, 2010 6:54 am

avg in two subreport

Post by majidsoft »

hi
your code is not working i send a sample for you
if my text in sub reports have null value i dont want to use it in avg
thanks
Attachments
523.Report sample.mrt
(12.4 KiB) Downloaded 293 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

avg in two subreport

Post by Alex K. »

Hello,

In SubReport1 use {Avg(DataBand3,khashak["akhash"])}
In SubReport2 use {Avg(DataBand2,khashak["khash"])}
And in Text3 use expression: avg= {(Avg(DataBand3,khashak["akhash"])+Avg(DataBand2,khashak["khash"]))/2}

Thank you.
majidsoft
Posts: 66
Joined: Fri May 07, 2010 6:54 am

avg in two subreport

Post by majidsoft »

hi
in text3 if databand 2 have null value avg not working and get it 0 i want if any avg(text box) in subreport has null value not coming in main avg
thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

avg in two subreport

Post by Alex K. »

Hello,

You can use variables.
Add variables avg1 and avg2.
On Events "Before Print" FooterBand1 in SubReport_1: Avg1 = Avg(DataBand3,khashak["akhash"])
On Events "Before Print" FooterBand2 in SubReport_2: Avg2 = Avg(DataBand2,khashak["khash"])

And in Text3 use expression: avg= {(Avg1+Avg2)/2}

Thank you.
majidsoft
Posts: 66
Joined: Fri May 07, 2010 6:54 am

avg in two subreport

Post by majidsoft »

hi
i do your advise but i face with error can you send me a sample
thanks
Post Reply