I have 2 columns in MySQL table:
column1, column2
How to display a column "total" in which the sum of this columns in CCv6?
In MySQL it will be:
SELECT column1, column2, (column1 + column2) as total FROM table_name;
Is it possible in CCv6?
And give me pls link to good documentation.
I didn't find it.
Thank you.
column1, column2
How to display a column "total" in which the sum of this columns in CCv6?
In MySQL it will be:
SELECT column1, column2, (column1 + column2) as total FROM table_name;
Is it possible in CCv6?
And give me pls link to good documentation.
I didn't find it.
Thank you.
Hi Twickbot,
In the "Columns views" you will need to add this:
Then add a "php" function and set the name to "php_function_name", then add this code:
Unfortunately there is only 1 tutorial for v6 at the moment and its in the FAQs section, I'm trying to add more so hopefully soon.
Best regards,
Max
In the "Columns views" you will need to add this:
Model.field_total:{fn:php_function_name}
Then add a "php" function and set the name to "php_function_name", then add this code:
echo $this->get("table_view_name.row.Model.field_1") + $this->get("table_view_name.row.Model.field_2");
Unfortunately there is only 1 tutorial for v6 at the moment and its in the FAQs section, I'm trying to add more so hopefully soon.
Best regards,
Max
Thx for answer but I could not make it work.
My settings:
Views - Table20
Data provider:
Columns list:
As u said, I add to Columns views:
Functions - php16:
Result:
Table still show only 2 colums: Column1 and Column2.
Column "Total" did not appear.
What did I do wrong?
My settings:
Views - Table20
Data provider:
{var:stat_summary}
Columns list:
cloak_stat_summary.column1:Column1
cloak_stat_summary.column2:Column2
As u said, I add to Columns views:
Model.field_total:{fn:php16}
Functions - php16:
echo $this->get("table_view_name.row.Model.field_1") + $this->get("table_view_name.row.Model.field_2");
Result:
Table still show only 2 colums: Column1 and Column2.
Column "Total" did not appear.
What did I do wrong?
Hi Twickbot,
You need to define the column in the columns list or it will not appear:
Columns views:
PHP:
Best regards,
Max
You need to define the column in the columns list or it will not appear:
cloak_stat_summary.total:Total
Columns views:
cloak_stat_summary.total:{fn:php16}
PHP:
echo $this->get("Table20.row.cloak_stat_summary.column1") + $this->get("Table20.row.cloak_stat_summary.column2");
Best regards,
Max
Tnank u for answer.
It's much better now.
Appeared the third column. But, it is filled with zeros.
What else do I need to correct to get the sum of the first two columns in the third column?
It's much better now.
Appeared the third column. But, it is filled with zeros.
What else do I need to correct to get the sum of the first two columns in the third column?
This topic is locked and no more replies can be posted.