0

I have 5 integer fields and I want to show the MEDIAN result for those fields in my content view. How to get the result?

  • 1
    You mean median of 5 fields of one node? Or over all nodes in result set? – Mołot Apr 25 '14 at 6:47
  • Use Views PHP module.. Where you can write custom logic.. – Anil Sagar Apr 25 '14 at 9:48
  • Molot median of 5 fields of one node – Anamika May 29 '14 at 10:08
2

You can use Computed Field module to achieve this.

About Computed Field

Computed Field is a very powerful field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of fields. So start cooking up your PHP based values!

| improve this answer | |
0

You can also achieve this by implementinghook_node_presave.

Act on a node being inserted or updated.

This hook is invoked from node_save() before the node is saved to the database.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.