LimeReport Forum
General Category | Основное => Discussion | Обсуждение => Topic started by: talaadun on September 05, 2016, 08:18:19 am
-
Hi, I am doing a table test using 1.3.11.
in the right bottom cell, I use script like this:
$S{SUM($D{mydts.column1},"DataBand1")}+$S{SUM($D{mydts.column2},"DataBand1")}
it should display 56+72, but actually it is 56+56, why?
[вложение удалено администратором]
-
and here is part of the template:
[вложение удалено администратором]
-
Maybe better way is to use new datasource
add new datasource in DataBrowser, then arrange your connection in Connection combo, named new datasource and
assign SQL query like rhis
select (sum(mydts.column1)+sum(mydts.column2)) as needed_sum from mydts where... (if you want to use condition)
and then use $D{new_datasource.needed_sum}
Also you can use master-detail scheme
-
Thank you very much, Subst.
Unfortunately my table data is from a data struct in memory, not queried from a real database. And i am using SIGNAL SLOT
mechanism for external data sources according to the user manual.
master-detail scheme can solve this problem? I am not familar with it, let me try it.
Thanks!
-
Well, in such case easy way next:
create to variables sum1 & sum2
then in Total Column1 write code
$S{
var sum=SUM($D{mydts.column1},"DataBand1");
setVariable("sum1",sum);
sum;
}
similarly in Total Column2
$S{
var sum=SUM($D{mydts.column2},"DataBand1");
setVariable("sum2",sum);
sum;
}
And finally in Total Total
$S {
$V{sum1}+$V{sum2};
}
-
Hi Subst,
I used your script, but there is an error: ReferenceError: Can't find variable: setVariable
-
You need to create two variables in Data Browser -> Variables and call them sum1 and sum2
did you do it?
-
Hi Subst,
Yes, I added variables: Column1Total, Column2Total, but it just display the error message.
[вложение удалено администратором]
-
May be your version of LM id too old.
Look at the "Functions" tab (on th right when duble click on the textitem)
Can you see there GENERAL section function setVariable ?
-
There is no GENERAL section, so I need a new version of LM?
I am using the designer in LR_1_3_11_binares_Qt5.5_VC2010_win32, and limereport_1_3_11.
-
1.3.11 seems to be the newest version of LM.
I am using VS2008 + Qt4.8.5, but i don't this this is the problem.
-
Yes. The binaries are old. The 1.3.11 version is newest in binaries but sources on github are greatly modern.
You can build LM from sources yourself .
or I try to solve your problem another way
As apparent variant - solve the needed value in your program and pass them to the report throw setReportVariable like this
m_report->dataManager()->setReportVariable("variable_name",variable_value);
"variable_name" variable must be exists in report, obviously
-
Well.
And why u can't calculate sum of "total" field?
-
Hi Subst,
I just downloaded the source code from github and built the entire solution. Now it works fine.
>> And why u can't calculate sum of "total" field?
Actually there is no "total" field in my data struct, this column is calculated by column1 and column2:
$S{$D{mydts.column1}+$D{mydts.column2}}
it seems that i cannot calculate the sum by "total" column.
Thank you so much for helping me solve this problem! :)
-
my pleasure
;)
-
i've fixed this bug and pushed it on github :) Now it's possible to do like this $S{SUM($D{mydts.column1},"DataBand1")}+$S{SUM($D{mydts.column2},"DataBand1")}
-
Hi Arin,
Now it's more convenient to display the total number.
Thanks! :)
-
talaadun, You are welcome :)