Our Biggest Sale Is Here
Up to 70% Off
Get the Deal

How to show totals, averages, minimum and maximum in wpDataTables

Say your stock table lists 40 products, and you want the total number of items in stock and the lowest stock level right below the table. wpDataTables calculates the sum, average, minimum and maximum of integer and float columns and shows them in a row at the bottom of the table. The results update when visitors filter the table, so a filtered table shows the totals of the visible rows. You can add them with Tabella AI or in the column settings.

How do I add totals with Tabella AI?

Open the table, click Ask Tabella AI and name the column and the calculation.

  1. Open the table. Go to wpDataTables → wpDataTables and click the table title.
  2. Ask Tabella AI. Click Ask Tabella AI and type, for example: Show the total of the Stock column below the table.
  3. Check and save. Tabella AI lists what it changed, for example Column “Stock”: total: enabled. Totals show after you click Save Changes and reload the editor. Click Undo table changes to go back instead.

How do I add totals in the column settings?

Turn on the calculations you need in the Data tab of an integer or float column and save the table.

  1. Open the table. Go to wpDataTables → wpDataTables and click the table title.
  2. Open the column settings. In the table preview, click the settings icon in the header of the number column.
  3. Choose the calculations. In the Data tab, turn on Calculate a total for this column under Calculate total, Calculate average for this column under Calculate average, Find a minimum value for this column under Calculate MIN value or Find a maximum value for this column under Calculate MAX value.
  4. Save the table. Click Save Changes. The results show in a row at the bottom of the table.
The Data tab of the Stock column in wpDataTables with Calculate total, Calculate average, Calculate MIN value and Calculate MAX value turned on and a shortcode below each
Calculations for a column: (1) the Data tab, (2) the calculation switches, (3) the shortcode of a result, (4) Save Changes.

How do I show a result outside the table?

Copy the shortcode shown below each calculation you turned on in the Data tab, with the copy icon next to it, and paste it into a post, a page or a cell of another table. A sum shortcode looks like this:

[wpdatatable_sum table_id=12 col_id=34 value_only=0]

The shortcodes for the other results are wpdatatable_avg, wpdatatable_min and wpdatatable_max. Two optional parameters work with all of them:

Parameter What it does Example
label Replaces the default label in front of the value. label="Items in stock"
value_only 1 shows only the number, without the label and the HTML around it. 0 (in the copied shortcode) shows the label too. value_only=1

To use a shortcode inside a cell of another table, turn on Parse shortcodes (Parse shortcodes in strings) in wpDataTables → Settings → Main settings. You can also use the results in formula columns.

  • Calculations work only for integer, float and formula columns.
  • Simple tables and charts can’t use calculations.
  • Results are not included in exports from the table tools.

What should I remember about calculations?

Ask Tabella AI, or turn on Calculate total, Calculate average, Calculate MIN value or Calculate MAX value in the Data tab of a number column, to add a results row below the table. The results follow the filters. Copy the shortcode of a result to show it elsewhere, with label and value_only to change how it looks.

Wait, Before You Download!

To get your hands on wpDataTables Lite, please enter your email address below. We’ll send you a direct download link and keep you updated on existing features along with helpful tips and tricks!

By continuing, I accept Privacy Policy and T&C
Mail Box