Location in report where to assign variables

Stimulsoft Ultimate discussion
Post Reply
Artimidor
Posts: 38
Joined: Thu Jan 09, 2020 8:15 am

Location in report where to assign variables

Post by Artimidor »

Where is one supposed to assign a variable, so that it doesn't show up in the report but can be used later?

My initial thought was to output the value and then assign it to the variable I'd like to use later. The content of the textbox looks like this:

{Sum(ProductTotals.Amount)}
{varTotalAmount=Sum(ProductTotals.Amount)}

In preview, everything looks fine. The value is displayed and the variable now contains the value, which I can output later. But once I fill the report with actual data, two rows are being displayed instead of one. The value appears twice??
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Location in report where to assign variables

Post by HighAley »

Hello.

It seems that you are using our different report engines.
If you need to get the sum anywhere else you could use the same expression.
The same sums are cached. Or you could try to use the report events to save the value.
It's better to use the GetValue event of this text component.

Thank you.
Artimidor
Posts: 38
Joined: Thu Jan 09, 2020 8:15 am

Re: Location in report where to assign variables

Post by Artimidor »

I fear, both approaches don't work.

When I move the code {varTotalAmount=Sum(ProductTotals.Amount)} into the GetValue event of the text component and preview it I get the error "Sum is not defined". varTotalAmount is still zero.

Likewise, when I try to access a sum in another data-band by simply referring to it with Sum(ProductTotals.Amount) the value is wrong. There seems to be some calculation going on (the value is not zero), but the output is wrong nevertheless,
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Location in report where to assign variables

Post by HighAley »

Hello,

Please, send us your report template with sample data for analysis.
Also we need to know where and how do you run the report.

Thank you.
eirajeremy
Posts: 1
Joined: Mon Mar 18, 2024 7:19 am

Re: Location in report where to assign variables

Post by eirajeremy »

Hi
In order to assign a variable that doesn't show up in the report but can be used later, you can assign the value to the variable directly without outputting it first. This can help prevent the value from displaying multiple times when the report is filled with actual data. For example:

{varTotalAmount=Sum(ProductTotals.Amount)} my location

By assigning the value to the variable without outputting it, you can ensure that it is stored for later use without affecting the appearance of the report.
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Location in report where to assign variables

Post by Lech Kulikowski »

Hello,

Thank you for the information.
Post Reply