Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • CDMS
  • Castor CDMS Calculations Manual
  • General calculation templates

Calculating with numbers in grids in EDC/CDMS

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • CDMS
    Castor CDMS Manual Castor CDMS Calculations Manual Frequently Asked Questions Articles for Data Managers Castor CDMS Compliance Release Documents
  • eConsent
    Castor eConsent Manual Castor eConsent Compliance Release Documents
  • SMS
    Castor SMS Manual Castor SMS Compliance Release Documents
  • Castor Connect
    Castor Connect Compliance Release Documents Castor Connect Manual Castor Connect - Participant Quick Start Guide
  • Helpdesk
    News Other Resources Castor products knowledge resources
  • Status page
  • Completing a Study
+ More

Table of Contents

Calculate the sum of a row within one grid Calculate the sum of rows within multiple grids

The instructions described in the article Calculate with grid fields renders the objects in string (plain text).

 

If you want to do mathematical operations with numbers, you will need to convert that text into numbers. For that you would use the parseInt() function. 

 

Calculate the sum of a row within one grid

For example, we want to get the sum of the values in the first row of the grid shown below:

 

To get the sum of the first row (in this case it is 16), we would use:

 

parseInt(Object.values(obj[0])[0]) + parseInt(Object.values(obj[0])[1]); 

 

You cannot calculate with a (half-)empty grid field - all the cells that are used in the calculation have to be filled in the grid to be able to execute the calculation.

 

If the numbers contain decimals we will need to use the function parseFloat() instead. For example, we want to get the sum of the values in the first row of the grid shown below:

 

 

To obtain as result 29.5 we have used this code:

 

parseFloat(Object.values(obj[0])[0]) + parseFloat(Object.values(obj[0])[1]);

 

Calculate the sum of rows within multiple grids

Below we will show you how to calculate the value of two separate grids. For this example, we want to calculate the sum of the values entered in Grid 1 and in Grid 2 as shown below:

To get the sum of the cells (in this case 15), we would use:

var obj = JSON.parse('{grid_1}');
var sum_grid1 = parseInt(Object.values(obj[0])[0])+parseInt(Object.values(obj[0])[1]);
var obj2 = JSON.parse('{grid_2}');
var sum_grid2 = parseInt(Object.values(obj2[0])[0])+parseInt(Object.values(obj2[0])[1]);
sum_grid1 + sum_grid2;


It is also possible to calculate the sum of only several cells in the grid, for example Column 1:Row 1 in Grid 1 and Column 1: Row 1 in Grid 2:

 

Below is the calculation template to calculate the sum of Column 1:Row 1 in Grid 1 and Column 1: Row 1 in Grid 2:

var obj = JSON.parse('{grid_1}');
var output = Object.values(obj[0])[0];
var obj2 = JSON.parse('{grid_2}');
var output2 = Object.values(obj2[0])[0];
parseInt(output)+parseInt(output2);

When calculating with some cells of the grid, all the cells that are used in the calculation have to be filled in both grids to be able to execute the calculation.

edc-cdms grid maths

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Calculate with grid fields in EDC/CDMS
  • Check if all fields are complete (and list empty fields) in EDC/CDMS
ISO 27001
FDA - 21 CFR part 11
ICH GCP compliant
HIPAA compliant
CDISC
ISO 9001
gdpr compliant

Products & Industries

  • Electronic Data Capture (EDC)
  • ePRO
  • eConsent
  • Decentralized Clinical Trials (DCT)
  • Clinical Data Management
  • Medical Device & Diagnostics
  • Biotech & Pharma
  • CROs
  • Academic Research

Resources

  • Thought Leadership
  • Blog
  • Castor Academy
  • Knowledge Base

 

Company

  • About Us
  • Careers
  • News
  • Contact Support
  • Contact Us

Legal & Compliance

  • Terms of Use
  • Privacy & Cookie Statement
  • Responsible Disclosure Policy
  • Good Clinical Practice (GCP)
  • ISO Compliance Certificates
  • GDPR & HIPAA Compliance
  • Security Statement

© 2022, Castor. All Rights Reserved.

Follow us on social media


Knowledge Base Software powered by Helpjuice

Definition by Author

0
0
Expand