For many cases, it is useful to calculate a sum, average, minimum and maximum of all the values for a given column. For example, total sales within a month, the total price of products in an order, calculating maximum profit, minimum wage, average grade etc. wpDataTables supports a sum / totals, average, minimum and maximum row for numeric columns, see this table as an example, and try to filter it by a date range to see how the totals recalculate:
One or more columns doesn't have a header. Please enter headers for all columns in order to proceed.
Adding all these features is simple. In the column settings, click on the Data tab and check the Calculate checkboxes for the selected column you want to calculate these functions.
If these checkboxes are checked for at least one row, a functions row will appear in the bottom.
Functions are recalculated on table redraw (i.e. when you filter).
Also take note of the shortcode below each calculated function.
By pasting the shortcode, you can display the results of the functions somewhere outside the table, or you can paste this code in a cell belonging to another table.
To achieve this you will need to check the Parse shortcodes option on the wpDataTables Settings page.
- Go to WordPress admin, and open wpDataTables
- Click on Settings
- Check the “Parse shortcodes” checkbox
Each calculation function shortcode have additional parameters that can be useful:
- label – You can overwrite label throw this shortcode parameter for example for sum(can be used for all shortcode calculation functions)
wpdatatable_sum table_id=2846 col_id=23013 label="My SUM label"]
By default this parameter is null and will be used value from Global label settings.
- value_only – If you need to show only value, without additional html around it you can pass this parameter with value 1. By default is set on 0. For example for average function to show only value (can be used for all calculation shortcode functions)
wpdatatable_avg table_id=2846 col_id=23013 value_only=1]
- Creating editable tables and filling the table data manually
- Creating non-editable tables from Excel files
- Creating non-editable tables from Google Spreadsheets
- Responsive design
- Conditional formatting
- Sorting tables
- Per-column filtering
- Pre-filter tables through URL
- Row grouping
- Using Placeholders – Adjusting MySQL queries dynamically based on shortcode attributes
- Table Layout, Word Wrap
- Table data export tools
- WPBakery Page Builder