Views Calc – Calculations for Your Fields in Views

Views Calc is useful little Drupal module that allows you to perform calculations inside Views.

Views Calc allows you to perform Count, Sum, Average or Minimum calculations on a single field.

Let’s see an example of how Views Calc works. To follow the example, you need both the Views and Views Calc modules to be enabled.

In this example, I created a content type called “Exercise”, with a field called “Miles jogged” that allows me to record how far I’ve run.

  • Go to Structure > Views > Add new view.
  • For your Display format, choose “Views Calc Table”. Views Calc does only offer the table format.

  • Click Continue & Edit.
  • Add the field you want to perform calculation on:

  • Click “Settings” next to the Views Calc Table format:

  • Under “Column Calculations”, check the box labelled “Display calculation”.
  • You can now decide which calculation you want to perform on the field. The four options are Count, Sum, Average and Minimum. In this example, I’ll choose “Sum”.

  • Click Apply all displays.
  • Save the view. You’ll now be able to see that Views Calc is working on your table:

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Article Rating
Subscribe
Notify of
3 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Nayana Rane
Nayana Rane
6 years ago

I have conditional fields and wants to calculate sum of it. how can i achieve this?

gilbertomangones
gilbertomangones
5 years ago

How do that in drupal 8?

Rajesh patalasingh
Rajesh patalasingh
2 years ago

In postgres it is difficult 

3
0
Would love your thoughts, please comment.x
()
x