Module Description
Based on https://www.drupal.org/project/views_cumulative_field, this module allows you to perform simple math expressions on two Views fields.

I created this because Drupal 8 Ctools does not currently have the Global Math Expression field that it had in Drupal 7.

Note: Twig can do math, but it's better to do math with PHP. This field is especially useful for site-builders who want to avoid Twig or who have a module like Charts that responds better to this module than a field rewrite.

Instructions After you enable this module (you may need to run cron/clear caches):


* Create/edit your view.
* Add fields as values on which you will perform your operation.
* Add the "Global: Simple Math Field" field (created by this module).
* Select the fields, and then add their tokens (e.g. @field_one) into the text area. An example operation could be '(@field_one / @field_two) * 100'.

That's it!

Versions 8.x-2.x
This version allows users to add multiple fields and operations into the same formula. It makes use of the "Eval-math" library. There is currently no upgrade path from 1.x to 2.x, but it's relatively easy to re-configure existing Views Simple Math Fields once you have updated (edit the view, configure the field, save). Would love someone to contribute an upgrade path! Here's what the 2.x field looks like:



3.0.x
This is nearly identical to 8.x-2.x, except it now relies on a fork of the "Eval-math" library to accommodate PHP 8+.

Contributing If you are interested in helping out with this module, please submit patches or contact me directly.

Project Usage
1415
Creation Date
Changed Date
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module aims to solve the lack of a Global Math Expression field in Drupal 8 Ctools by allowing simple math expressions on two Views fields using PHP instead of Twig.
Data Name
views_simple_math_field

OPENAI CHATBOT

OPENAI CHATBOT

14:32:40
Generic Chatbot
Hi, I'm a Drupal module expert powered by OpenAI, answering your questions about the Drupal module ecosystem. How can I be helpful today? Please note that we will log your question.