Page 1 of 2
Add two fields on the report
Posted: Fri Jun 19, 2015 11:17 am
by russr999
Hi...
Really hoping somebody can help.
I have a report connected to a SQLite datasource. I ahve a number of fields in the report.
I have added a text box to my report and I want to add two existing fields on the report together.
QUESTION: How can I add two existing fields together in a textbox on my report
eg:
textbox1 = {SQLitequery1.YetToSpend}
textbox2 = {SQLitequery1.TotalSpent}
textbox3 = ??????????
I have tried
- {textbox1 + textbox2} - Fails with error: Operator '+' is not defined for types 'Stimulsoft.Report.Components.StiText' and 'Stimulsoft.Report.Components.StiText'.
- {textbox1.value + textbox2.value} - Fails with error: 'value' is not a member of 'Stimulsoft.Report.Components.StiText'.
Thanks,
Rory
Re: Add two fields on the report
Posted: Fri Jun 19, 2015 11:37 am
by Alex K.
Hello,
Please try to use the following expression:
{SQLitequery1.YetToSpend + SQLitequery1.TotalSpent}
Thank you.
Re: Add two fields on the report
Posted: Thu Jun 25, 2015 10:36 pm
by russr999
Hi Aleksey
I explained it poorly.
Is it possible to just refer to the textbox value and not have to refer again to the datafield that is populating the previous textbox.
Can I refer to the textbox2 value and not the {SQLitequery1.TotalSpent} field?
Thanks
Re: Add two fields on the report
Posted: Fri Jun 26, 2015 12:00 pm
by Alex K.
Hello,
This is restriction of using named template components in report. During report rendering exist two instance of each component (minimum two instance). One instance - component in report template. Second instance - component which created for rendered report. During creation of second instance report engine calculate expressions and write it to second instance. When you write expression like this:
{Text1.Text}
you call instances from report template which does not contain calculated values from expressions.
You can:
1. Instead of "{Text1.TextValue}" expression use the same expression as in Text1.Text property, or
2. Use variables. In this case you can calculate value in variable, and then use this variable in expressions.
Thank you.
Re: Add two fields on the report
Posted: Sat Jan 14, 2017 11:52 am
by miguelcaro
HI,
I tried to show a calculate field in a Databand. For this, I add two numeric fields ( Field1, Field 2) in the databand and a new text objet in the databand for calculate Field1 + Field 2
In the expression text objet I write the next expression and It does not work:
{ Datasource1.Amount1 + Datasource1.Amount2 }
This expression also fails:
{ Datasource1.Amount1 * 5 }
Could you document the possible expressions with string and numeric fields? It is not clear.
Thanks. We note a lot of improvements from 6 months ago
Notes:
Firebird 2.5 Database connection
Re: Add two fields on the report
Posted: Sun Jan 15, 2017 9:48 am
by Alex K.
Hello,
Please send us a simple report with test data which reproduces the issue for analysis.
Thank you.
Re: Add two fields on the report
Posted: Sun Jan 15, 2017 1:17 pm
by miguelcaro
I solved this problem when I realized that all fields in my datasource (Firebird 2.5) were all Strings. I edited the string fields to double and now it works. Now, the question is ...
Why php Stimulsoft does not keep fields types when you create the datasource? . It is a problem because we need always to remember to change all numerics fields in the datasource.
Thanks for the quick response.
Re: Add two fields on the report
Posted: Sun Jan 15, 2017 7:45 pm
by Alex K.
Hello,
Could you explain your issue in more details?
Also, please clarify which version are you use?
Thank you.
Re: Add two fields on the report
Posted: Mon Jan 16, 2017 4:28 pm
by miguelcaro
Since the datasource that we connect to Firebird 2.5 returns all the fields in String format, when we design a databand with 2 fields, supposedly numeric, we can not perform calculations with them. Stimulsoft php forces us to edit in the datasource, the string fields to numerics (double).
Datasource1.Amount1 and Datasource1.Amount2 are StringField in the datasource. If you put a new text object and edit it with this expression. The report fails.
{ Datasource1.Amount1 + Datasource1.Amount2 }
But... if you edit this two fields to "double" in the Datasource , Report works fine.
Re: Add two fields on the report
Posted: Mon Jan 16, 2017 10:49 pm
by Alex K.
Hello,
Please clarify which version are you use?
Thank you.