


Table of Contents
If your dataset used for wpDataTable creation is not comprehensive – if for example, it shows only the price without VAT tax, or you need a column showing a result of calculation based on other columns’ cell values, you can use the formula (calculated) columns.
See this table: “Tax” and “Difference” columns do not exist in the dataset. They are calculated “on the fly” using the formula columns feature.
Any table can have a formula column. To add one, you can click the “Add a formula column” button:
After you click the “Add formula a column” button, you will see a popup formula constructor. It has a fixed name ‘formula_1’, ‘formula_2’, etc. – depending on the amount of formulas that you added.
The formula constructor popup has several main elements:
Additionally, there is an explanation text on the top.
You can use columns (values for each cell will be inserted), or number values. Only numeric columns are allowed (non-numeric will be parsed as 0). Basic math operations and brackets are supported. Example: col1*((col2+2)-col3*sin(col4-3)).
To calculate the “Tax” column in the above example, we can simply use the catalog cost column value, multiply it by some number, and click “Save“.
Now let’s change the displayed header of the formula column. To do that, click the button for column settings.
Enter the new value in the “Displayed header” input in the first tab column setting and click apply.
If you want to change the formula for a calculation you can go to the “Data” tab and click on the “Open Formula Editor” button.
After you click on THE “Open Formula Editor” button, the formula constructor popup will appear. You can use it to adjust the formula that is used for calculation.
Formula columns can be easily deleted by clicking the “Delete” button in the column header area in the live table preview.
There are several limitations when using formula columns in wpDataTables:
Click here to see this table in our sandbox site or here to play around with back-end configuration.
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!