Thread:Guy Bukzi Montag/@comment-34326785-20200107214103/@comment-34918040-20200108034610

Yes, that's possible.

Tables as such cannot calculate, templates can. The trick is to split the table into
 * a table header that only provides the header row and a closing bracket at the end
 * a table row that takes the values and calculates with them.

Table header stats a8 and Table row stats a8 work this way, but they are perhaps a bad example because they are full of parameters for backwards compatibility.

The simplest way would be:


 * Header template


 * Row template

To display the table on a page, the code would be


 * Note that templates use two curly brackets, parameters use three.
 * The parameter  in the header means: It is the first unnamed parameter, hence the number. The pipe   means "if omitted, then display". Without pipe, the text "  " would be displayed if an editor omitted the parameter, which is mostly unwanted. The pipe says: If the first parameter is omitted, then display nothing.
 * In our example, we send the table row as parameter to the header which constructs the table.
 * and  are named parameters. Normally it is more useful to use speaking parameters names. I chose a and b for simplicity.
 * The first table row column displays  or nothing, the second displays   or nothing, and the third builds the sum of   and.
 * is not a template, but a parser function. You can recognize parser functions by the colon instead of the pipe. Many but not all parser functions are also preceded by a hashtag.  is where your formulas go.
 * treats everything after the colon not as text like templates do, but as something to compute. It needs "clean" parameters. We don't know if an editor forgets to provide one of the parameters, so just in case, we use  or zero  and   or zero, so there's always something to add. Otherwise, a nasty  could occur.
 * Wikipedia has much information about parser functions and what they can do.
 * General: https://meta.wikimedia.org/wiki/Help:Parser_function
 * Hardcore computation: https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions

Good luck with your project and happy coding!