R-fields

Reporting > Report Helpers > Fields > R-Fields

Calculated Reporting fields, also known as R-fields, are used to calculate aggregate scores across feedback records. R-fields look at all records (unless otherwise indicated in the calculation) instead of looking at individual ones.

R-fields can be used anywhere where reporting is conducted at an aggregate level across feedback rather than at the individual record level. Common modules that reference R-fields include Satisfaction, Ranker, Custom modules, and Dashboards.

Properties

Label
Label is a unique identifier for an R-field. The label should always start with the company name to ensure that it is unique across all instances. Be aware that this cannot be changed once saved.
Name
Name of the R-field that will appear in Reports. This can be changed at any time.
Restriction: Name can have a maximum of 63 characters.
Category (optional)

Groups all definitions with the same Category value together, which can make them easier to find on the list. Definitions are ordered by Priority inside each category. Definitions with no Category value are listed underneath. Use the filter above the list to see just the definitions of the selected category.

The act of assigning a definition to a category that doesn't exist creates a new category. Note that category names are case sensitive.
Note: To delete or change the name of a Category, simply change the Category value in each of the definitions that belongs to it.
Priority
Priority specifies the order in which the fields appear in the list of R-fields. R-fields with the same priority will be listed alphabetically.
Description
Description is used to capture details about the R-field calculation that will help others understand the functionality of the field.
Integer calculation

If this box is checked, the R-field calculation is assumed to always be an integer (e.g., number of invites, number of Alerts), and will not display any decimals in the Invitation Ranker and Ranker, though when clicking through to Satisfaction the decimals will appear again.

Note that all other reports display the original number of decimals for this field.

Disable validation
Disable the JavaScript validation that normally runs; this is useful to access certain advanced functions that the validation doesn't know about and thus prevents you from saving.
CalculationType and Calculation

Use the CalculationType dropdown to choose the calculation type that should be performed for this R-field. The Use the Calculation property to provide the appropriate parameters for the selected calculation type. The syntax for each type is listed below.

Restriction: The R-field JavaScript editor only shows records that are COMPLETED (e_status = 1). To test R-fields that report on invitation data (e_statuses other than 1), use a test Dashboard and a Module. For more information, see JavaScript editor.
Calculation typeCalculationSyntax
Net Promoter ScoreCalculates the NPS of a single field, which is the percentage of Promoters (9-10) minus the percentage of Detractors (0-6 or 1-6). This field must have alternatives with numeric values in the range 0-10 or 1-10.q_companyname_ltr_scale11_alt
Top Box (or any segment fraction)

Calculates a Top Box or any other segment fraction of the field.

For example, when calculating % of promoters, we return those responses with a score of 9 or 10. In order to calculate the percentage of 9 and 10 for a Q-field, the mention of the respective Q-fields needs to be followed by the range of numbers: 9-10.

q_companyname_ltr_scale10_alt9-10

Count (number of samples)Calculates the number of samples. In order to calculate the number of the invitations sent, we can use Count as the calculation type. Only the mention of the Q-field in the Calculation field is required.q_companyname_number_responses_alt
Average (of sample values)Calculates the average of the sample values. Only the mention of the Q-field in the Calculation field is required.

Sample input: This sample of code will average the OSat field for food.

This calculation only supports one field at a time.

q_companyname_food_osat_alt

Sum (of sample values)

Calculates the sum of the sample values. Only the mention of the Q-field in the Calculation field is required in order to calculate the sum of the numeric value of the sample values.

Sample input: For instance we have a call center manager who wants to calculate the sum of Overall Satisfaction scores of his employees from the customers in a survey; we can create an R-field to calculate this.

Restriction: Negative values for an integer alt-set E-field do not get summed up via the JavaScript sum function, and instead, the value of the sum is set to zero within an R-field.
q_companyname_customercare_osatscore_alt
Weighted average of the samples from a set of fieldsWeighted average is calculated as the sum of values from a set of fields divided by the count of values from the same set of fields. This means that fields with more samples will have a higher weight and thus influence the final number more. Only the mention of the Q-fields in the Calculation field is required in order to calculate the weighted average.

q_companyname_courtesy_friendliness,

q_companyname_knowledge_helpfulness

Average of the calculated values of a set of fieldsCalculate the average of the calculated values (based on what is selected in the Calculation Dropdown of the report being viewed) for a set of fields. Unlike weighted average each field has equal weight and thus the same influence on the final number. For example, if there are two fields and the average calculation is selected the value is the average of the average value of those two fields. Only the mention of the Q-fields in the Calculation field is required in order to calculate the average of the calculated values.

q_companyname_courtesy_friendliness,

q_companyname_knowledge_helpfulness

Percentage Yes on a Yes/No fieldCalculates the percentage of Yes answers of a field that must have the Yes/No alternative set; note that null (no answer) values are counted as 'No.' For displaying the count / sample size in a report, the number of Yes answers will be used. Only the mention of the Q-field in the Calculation Field is required in order to calculate percentage Yes on a Yes/No field. q_r_svu_visit_thanked
Delta Impact Helps in analyzing the impact of a certain set of data against another set, mostly used in Medallia Text Analytics. It prioritizes the areas with the greatest negative/positive impact for improvement/sharing of best practices.Assuming the aggregate calculation is NPS, this is the formula used:

(NPS(topic)-NPS(total))*num(topic)/(num(total)-num(topic))

Scaled Delta ImpactThis is similar to the Delta Impact score calculation except scaled to basis points (multiplied by 100). It is similar to Medallia Impact Index.None provided

Any custom calculation that needs to be coded and which is not included in any of the calculation types above can be done in custom JavaScript. For more information, see JavaScript functions.

Important: Medallia Experience Cloud uses a JavaScript processing engine called Mozilla Rhino — also known as the Rhino Engine — to provide flexibility for scripting. Access to the Rhino Engine is restricted by a ClassShutter mechanism, which implements arbitrary logic to determine whether Rhino can access the class. When access is denied, Experience Cloud shows an error message. To access a class that is not currently allowed, contact your Experience Cloud expert. For more information, see JavaScript allow-listing.

The following table lists examples of JavaScript in R-fields:

Calculation typeCode
Hard Coded Weighted Average
combine( 
weight(cube.field('q_r_svu_pilot_core_courtesy_friendliness'), 0.15), 
weight(cube.field('q_r_svu_pilot_core_knowledge_helpfulness'), 0.075), 
weight(cube.field('q_r_svu_pilot_core_helpfulness_of_staff'), 0.075), 
weight(cube.field('q_r_svu_pilot_core_product_availability'), 0.20), 
weight(cube.field('q_r_svu_pilot_core_quality_of_fresh_food'), 0.15), 
weight(cube.field('q_r_svu_pilot_core_overall_cleanliness'), 0.15), 
weight(cube.field('q_r_svu_pilot_core_speed_checkout'), 0.15), 
weight(cube.field('q_r_svu_pilot_core_overall_value'), 0.05) ).avg*10
Percent No in Yes/No/NA

var num = cube.cut('q_company_tech_findup_ynna', ['No']).count ;
var den = cube.cut('q_company_tech_findup_ynna', ['Yes','No','Not Applicable']).count;
if (den === 0) {
  return null;
}
else {
  return 100*(num/den);
}
Number of Surveys with Alerts
cube.cut('a_Alert_triggered','Yes').count
Number of unique agents with at least one associated feedback record
(function() {
	var unitCount = cube.aggregateUnique('e_bp_cc_agent_unit').count;
	if (unitCount == null || unitCount === 0) return null;
	return unitCount;
})(); 
Sample Size
cube.cut('e_status', ['COMPLETION_PENDING', 'COMPLETED', 'SURVEY_ENGINE_ONLY', 'DELIVERED', 'DELIVERED_AND_REMINDED', 'DELIVERED_NO_REMINDER', 'EXPIRED', 'DELIVERY_FAILED','TEST_SURVEY', 'DELIVERY_BOUNCED', 'EXCLUDED','INVITATION_RESENT','RESET']).count
Weighted NPS

Calculates the weighted NPS of a single field that must have alternatives with numeric values in the range 0-10 or 1-10.

For example, Company A assigns each property a weight, which is applied at the final step (that is, Average of Averages).

Weight

  • 5th Avenue = 128.61
  • Grand New York = 1055.87

LTR (regular NPS calculation)

  • 5th Avenue = 20.8
  • Grand New York = 66.7

LTR (weighted NPS calculation) for both properties = (128.61 * 20.8 + 1055.87 * 66.7) / (128.61 + 1055.87)

Make sure to test your calculation with the Run button and review the resulting output of the calculation.

Note: Changes to calculated reporting fields may require a log out and log back in to take effect.

R-fields library

Medallia Experience Cloud provides an R-fields Library which contains commonly used R-field calculations.

Library of calculations for R-fields.

Tips and best practices

The following are tips and best practices to follow to obtain optimal results when creating and using R-fields:

  • Keyname / Label must be only lowercase English letters, numbers or underscore, and must start with a letter.

  • The Integer Calculation (IM Ranker) checkbox should be selected only when there is a need to have a rounded off calculation to the nearest integer, for calculating metrics like number of responses or number of Alerts.

  • The Calculation type selection should be based on the requirement of the calculation. Each type of calculation has a specific format of the code. For instance, the average is used for calculating number of average and hence only a Feedback field would be required to be passed in calculation field but if the Top Box is used then a particular Feedback field needs to be passed in Calculation field followed by a range of number for which a Top Box range is calculated.

  • K-fields fields and Feedback fields should be validated and backfilled prior to usage.

  • Make sure to save any changes made to an R-field before closing it. User can also close it without saving if it’s not required to incorporate any changes made.

  • Make sure to compare the result of a calculation with the RI export. It can be checked by comparing aggregated data from export generated file. For example, if an R-field is created to find the number of surveys completed, the result should also reflect in the export data with the same number of records as survey status as completed. In the example below, the R-field Satisfaction percentage shows the percentage of respondents have replied as Very satisfied or Satisfied for Feedback field. This can be cross-checked from the exports generated from the system to find out the similarity in R-field calculation. R-field Satisfaction showing the percentage of respondents that have replied as Very Satisfied or Satisfied

  • Avoid using custom JavaScript, which can slow R-field calculations. If you need to use custom JavaScript optimize your code by avoiding repeated calculations and by not declaring variables at the beginning of your code.

    Important: Be especially judicious about using cube.agregateUnique functions in R-field JavaScript. In split queries, Experience Cloud returns a maximum of 1.5 million splits. Using cube.agregateUnique in an R-field can result in splits far greater than the maximum, especially when multiple cube.aggregateUnique functions are used in the same JavaScript calculation.

    Evaluate your existing R-fields for possible performance improvements:

    1. On the Reporting > Report Helpers > Fields > R-Fields screen, filter the list of fields by Used fields.

    2. From the Bulk menu, select Bulk Download (tabs).

    3. Open the file in Microsoft Excel, and filter the data for CalculationType = CUSTOM_JAVASCRIPT.

    4. Study the code for each R-field using custom JavaScript, and determine whether custom code is still needed. For example, a field might be using old code which has since been replaced with standard functions. You might be able to replace an R-field with a K-field that uses standard calculations. You might be able to replace a single R-field with a set of R-fields that use standard calculations and/or simplified JavaScript.

    5. Determine which reports use R-fields with custom JavaScript, and identify whether performance is slow for those reports. Use the Inspect capability of your browser to view the load time of the report. Replace the custom JavaScript R-field with your optimization, and then view the load speed of the report again. If the load time is faster, use the optimized R-field. For example, the following image shows where to identify the load time when using the Inspect function in a Chrome Browser:

      Where to see the Load time in a Chrome browser

See Programming idioms for JavaScript best practices, a reference of JavaScript functions in Experience Cloud, and for more tips about how to use the editor.

Troubleshooting

These are common troubleshooting issues as well as how to resolve them.

Missing semicolon before statement

The missing semicolon before closing the parenthesis of a function will generate an error. To solve this, include a semicolon before closing the parenthesis.

Missing semicolon before the statement generates an error

Missing semi-colon inline

While editing the code for an R-field, the representation of a cross image represents a missing semicolon. To solve this, provide the semicolon in the code.

Missing semicolon inline generates an error

Check for missing data

Calculation type should match the parameter passed in the Calculation field. To solve this, ensure that the parameter is passed in Calculation:

Field used for the CalculationType must be included in the calculation

Expected to create by key, but found CalculatedReportingField identifier

When the Label (Identifier) used is the same as an existing label, the following error is generated:

An error is generated when a calculation includes a label already being used.

To solve this, create a unique Label for an R-field.

Failed to validate calculation (tried to find identifier)

If the Feedback field is used to calculate the R-field is not backfilled, it may result in a failure to validate the calculation. To solve this, the data for the R-fields calculation needs to be backfilled before it is used in the calculation field.

If the Q-field used to calculate the R-field is not backfilled, it may result in a failure to validate the calculation.

Examples

Example 1:

To calculate the number of invitations sent, we can create the R-field that returns the value of the count of invitations sent.

To create such the R-field, the Calculation type needs to be customized and hence the use of custom JavaScript needs to be used.

cube.cut('e_survey_source', ['INVITED']).cut('e_status', ['COMPLETION_PENDING', 'COMPLETED', 'SURVEY_ENGINE_ONLY', 'EXCLUDED', 'DELIVERED', 'DELIVERED_AND_REMINDED', 'DELIVERED_NO_REMINDER', 'EXPIRED', 'DELIVERY_FAILED']).count

Example 2:

To find the percentage of new Alerts, we can create the R-field that returns the value of the percentage of new Alerts.

To create such the R-field, the Calculation type needs to be customized and hence the use of custom JavaScript needs to be used.

f = function() {
var num = cube.cut('k_ihs_Alert_status','New').count;
var den = cube.cut('a_Alert_triggered', ['Yes']).count;

if (num === 0 || den === 0) {
return null;
}

return 100*(num/den);

};
f();