Sum of Data Column in DataSource

Stimulsoft Reports.WEB discussion
Post Reply
jamesmuir
Posts: 23
Joined: Tue Feb 25, 2014 8:19 pm

Sum of Data Column in DataSource

Post by jamesmuir »

I have a simple datasource (datasource1) that contains two columns. There are two records in this datasource that contain numeric values. My data looks like this

ID VALUE
0 2.5
1 3

I am trying to display the sum of the data in the VALUE field in a text component. My expression is this
{Sum(datasource1.VALUE)}

If i place the text component directly in the report, it only returns the first value in the output (2.5).

If i drop the text component into a databand, the correct value appears (5.5) but is repeated (because the databand renders the value for each record in the datasource). Is there a correct way to accomplish what I am trying to do? It seems like it would be a simple task but it is eluding me currently. Thank you.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Sum of Data Column in DataSource

Post by HighAley »

Hello.

The Sum function can't work properly without Data Band.
Please, try to use next expression:

Code: Select all

{Sum(datasource1, datasource1.VALUE)}
Thank you.
jamesmuir
Posts: 23
Joined: Tue Feb 25, 2014 8:19 pm

Re: Sum of Data Column in DataSource

Post by jamesmuir »

Thank you. I received an error when using the datasource name. I created an empty databand, placed the text component outside of the band, and referenced the databand as such.

{Sum(databand1, datasource1.VALUE)}

It now works. Thank you.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Sum of Data Column in DataSource

Post by HighAley »

Hello.

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
User avatar
dmasterplan
Posts: 143
Joined: Thu Mar 17, 2022 4:04 am
Location: Philippines

Re: Sum of Data Column in DataSource

Post by dmasterplan »

Mine didn't work. I did this:
I created a new calculated column and put this in expression: {Sum(DatadsPackages, dsAwardedContracts.Awarded)}
Need help.

Thanks
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Sum of Data Column in DataSource

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank you.
User avatar
dmasterplan
Posts: 143
Joined: Thu Mar 17, 2022 4:04 am
Location: Philippines

Re: Sum of Data Column in DataSource

Post by dmasterplan »

Worked now. I just misspelled the variable I assigned it too. Thanks!
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: Sum of Data Column in DataSource

Post by Max Shamanov »

Hello,

You are welcome!
Post Reply