How to sum two or more collums in table format?

dhuizinga1 10 Oct, 2016
Hi Bob, Hi Foks

I have 4 collums in my table which I will calculate

the value form colum 1 and colum 3
plus the value from colum 2 and 4

I'm a newbie wirth CFv5... so i don't get an idea IF this possible and if yes how this works.

I user CFv4 in Table format and not with custom code... thats a stap to far me i think 😀



I hope there someone who can help me with this
GreyHead 11 Oct, 2016
Hi dhuizinga1,

You can use the Front List > Settings > PHP Functions box to create new column values as functions of the other columns.
WG1617.total_a:return $row['set-1-a'] + $row['set2-a'];


Bob
dhuizinga1 11 Oct, 2016
Hi Bob,

Thnx for the quick answer.. I think the solution is near but not yet correcty...

As you can see I add you solution. (Pic 1)
I add by Columns list the coloms A & B (Pic 2)

With this construction I don't get an error on my screen but the result is zero in both columns..
what do i wrong?
GreyHead 11 Oct, 2016
Hi dhuizinga1,

By all means email or PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look. I think that some temporary debugging code may be needed to see exactly what is happening.

Bob
dhuizinga1 12 Oct, 2016
done...

send you a pm with login
GreyHead 12 Oct, 2016
Hi dhuizinga1,

Fixed I think, I had forgotten to include the model ID in the code:
WG1617.total_a:return $row['WG1617']["set1-a"] + $row['WG1617']["set2-a"];
WG1617.total_b:return $row['WG1617']["set1-b"] + $row['WG1617']["set2-b"];

Bob
dhuizinga1 12 Oct, 2016
That´s it.... thanx bob
Arnold_S 13 Mar, 2017
Hi Bob

I need this kind of calculation in CCv6. I tried a php-function with this code .... but it doesn´t run.

Thx
Arnold
Max_admin 13 Mar, 2017
Hi Arnold,

You need to call the php function inside the table "columns views", e.g: {function:function_name}, and in the php function content you can use this code:

echo $this->get("table_view_name.row.Model.field1") + $this->get("table_view_name.row.Model.field2");


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Arnold_S 14 Mar, 2017
Hi Max

I tried to implement your suggestion ...... but no sum are shown in the listing. What´s wrong?

Thx a lot for your help
Max_admin 14 Mar, 2017
1 Likes
Hi Arnold,

I have updated my previous post with a form call example and code fix ("row" added), please update your setting and test again.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.