Skip Navigation

[Resolved] How to calculate results in Views?

This support ticket is created 4 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 4 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1792481

Tell us what you are trying to do?
I want to calculate the average of the last 5 results shown in Views.

The table is in this format:

<table>
  // Table head is hard coded into the View loop editor 
  <thead>
    <tr>
      <th>Year</th>
      <th>Sales</th>
    </tr>
  </thead>
  // For the year I use category to label the year
  <tbody>
  <tr>
    <td>2016 ([wpv-post-taxonomy type="category" format="name"])</td>
    <td>100 ([types field='sales'][/types])</td>
  </tr>
  <tr>
    <td>2017</td>
    <td>120</td>
  </tr>
  <tr>
    <td>2018</td>
    <td>80</td>
  </tr>
  </tbody>
</table>

Screenshot: hidden link

Is this possible with Views?

#1792645

Hello,

Unfortunately, there isn't such kind of built-in feature within Toolset plugins, the Toolset Views/Blocks plugin only display the results from database, it does not do the calculation.

You might consider custom codes, see WP document:
https://developer.wordpress.org/reference/functions/add_shortcode/