# Table

The Table entity allows the user to custom-specify tables.

Under the ‹year list› option, a table will present results of a given plan on a time period by time period basis (usually the year). The user can tailor the level of detail in the table to the specific requirements of the analysis.

An other option, the ‹budget› table type, allows for the definition of tables that will present side by side results corresponding to the various component plans of a Plan. This features allows, for example, production of such tables as crop budgets comparisons.

Depending on the value of the «Results as» attribute in the headers, the tables will be produced in an editor either in plain text or in web format (html code). The normal commands of the editor can be used to save and / or print the results. In case of html output the table will also be rendered in a pop-up window, and the rendered output can be printed using an external web browser. A table can also be exported to a spreadsheet file. See the section on Running a model for details.

A Table format is defined as a template structure that is available for any Plan in the model. It is activated by a command inserted in a Script, provided the script itself is included in the Plan.

When calculations are carried out for a given plan and such a table is requested then the program will use the elements of the template that are present in the plan and ignore the others.

### Table definition

A Table is defined by a unique ID, a label, a unit, followed by zero or more titles, a number of other parameters (see below), and a list of table blocks terminated by the ‹end› (or ‹fin›) keyword.

The other parameters are:

- totals : optional keyword indicating that an additional column will be added to include the sum of row values for the range of years being printed.
- allColumns : optional keyword indicating that all columns in the specified list should be printed. The default is that otherwise those columns with repeating values across the entire table will be automatically grouped into a single column. If for example all years in the range 1 to 10 are requested, but years 3 to 9 are identical for all the rows, then only four columns will be produced: 1, 2, 3-9 and 10.
- colWidth : optional value, applicable only to pain output (ignored if html output) - if a value is not specified, then the program will calculate the width of columns based on the largest number in the table.
- decDigits : optional value – can also be specified at block or table item level, the lowest definition applies. if no value is specified the default is 2.
- tabScale : optional value – if a value is not specified, then no scaling is applied to the entire table.
- Table type : mandatory – can be set to ‹yrlist› or to ‹budget›.
- years : mandatory – the list of years to be printed in the table, separated by a comma, or by a ‹~› to indicate a range of years : e.g. : [1, 3~5, 10] is the same as [1, 3, 4, 5, 10]. Table years must be in increasing order. For budget-type tables, the list can include 2 values at most.

### Table blocks

A Table block is made of :

- the keyword ‹block›, optionally followed by ‹=› and a title, optionally followed by ‹,› and ‹Block totals› to specify an additional row with the totals of each column, optionally followed by ‹,› and ‹decDigits› as explained at table level
- a list of Table Items
- the words ‹end› or ‹fin› followed by 'block'

### Table items

A Table item is made of :

- the reference to a results entity, that can be:
  - a Commodity result, made of the optional keyword comm _, the ID of the commodity, a tilde and a result-type attribute.
  - a variable from a Script, made of the optional keyword var _ and the ID of a global (i.e. not defined as local) variable.
  - an aggregated Herd result, made of the optional keyword herd _, the ID of the herd, a tilde and a result-type attribute.
  - a detailed-by-Class Herd result, made of the optional keyword herdClass _, the ID of the herd, a tilde, a detailed-result-type attribute, a tilde and the ID of a class of that herd.
- an optional label definition, that would replace the one of the referenced entity
- an optional footnote
- an optional decDigits specification, as above

A tilde is the ~ character, used as a separator between IDs and attributes.

The result-type attribute for a commodity can be consQ, prodQ, availQ, balQ, consV, prodV, availV ,balV , where the suffixes Q and V stand for Quantities and Values, and cons, prod, avail and bal stand respectively for consumed, produced, available and balance.

The aggregated-result-attribute for a Herd can take some fifty one different values. They are detailed in the corresponding Herd Results section of the herd reference page.

The detailed-by-Class result-attribute for a Herd can take four possible values: avgSize, deathRate, offtakeRate, intakeRate.

The syntax for specifying results is the same as the one used in scripts.

Back to top

### Table example

table Tableau_budgets_de_culture = ‹Budgets de culture› ;
decDigits = 2, Table type = budget, years= [1, 4];

block = ‹Rendement et valeur de la production›;
var_Tot_céréales, label = ‹Rendement (T/Ha)›;
var_Price , label = ‹Prix par tonne›;
var_Revenu_céréales;
end block;

block = ‹Couts de production›, Block totals;
comm_Travail~consV;
comm_Pompage~consV;
comm_Intrants~consV;
end block;

block = ‹Résultat par Ha (avant financement)›;
var_CashIncome, footnote = ‹Valeur de la production moins intrants et pompage›;
var_RevJour , decDigits=2 ;
end block;

fin;

Back to top

### Table templates

A table can be specified using the Table template:

table ID = ‹label› ; //, unit = ‹unit› ; // optional titles: STRING ; // totals, allColumns, colWidth=1, decDigits=2, tabScale=1, Table type = yrlist, years = [1, 3~6, 12]; //table blocks end;

A table block can be specified using the TableBlock template:

block ; // = ‹title› ; //, Block totals ; // , decDigits = 2; // table items end block;

A table item can be specified using the one of the four possible TableItem templates:

comm_CowMilk~consQ ; //, label = ‹label› ; //, footnote = ‹footnote› ; //, decDigits = 2; var_V1 ; //, label = ‹label› ; //, footnote = ‹footnote› ; //, decDigits = 2; herdClass_Herd1~avgSize~JF ; //, label = ‹label› ; //, footnote = ‹footnote› ; //, decDigits = 2; herd_Herd1~nbrTotal ; //, label = ‹label› ; //, footnote = ‹footnote› ; //, decDigits = 2;

Names and attributes are selected from possible values in drop-down lists.

Back to top