Calculations
Calculations define how to aggregate data from Event fields and K-Fields in reports. Calculations typically appear in filters on reports to allow the user to select an aggregation method, but they can also directly affect the results in Text Analytics reports and Custom modules without filtering. Common standard aggregations include NPS, Top Box, Count, and Average. Some of the standard calculations can be customized, and you can also create new custom calculations. Some calculations can be weighted to show results more inline with business factors.
Reports that include calculations in the configuration enable you to specify Use role default as the value. A role's default value is determined by a combination of the calculations available to that role (in the MemberRoles property) in order on the Calculations screen, and how those calculations apply to the report being viewed. For example, if a role has access to the first five calculations listed on the Calculations screen, but the first two are not applicable to the report being viewed, the third calculation listed is the default calculation for that role viewing that report. If a role has no calculations assigned, Average is used as that role's calculation by default.
NPS
The Net Promoter Score (NPS) of a single field in the set. NPS is calculated by subtracting the percentage of respondents who were detractors from the percentage who were promoters.
Traditionally, NPS is calculated on a scale of 0-10 or 1-10, where the promoter scores are 9 or 10, and the detractors are 6 or below. When the target field is a numeric (alternative set) in the range 0-10 or 1-10, this calculation type is built-in and requires no customization. Customize the NPS type when:
- The field is not in the traditional scale.
- The range of promoter is not 9-10.
- The range of detractors is no 6 or below.
To define a custom NPS, define the ranges for promoters, detractors, and scale in the Calculation field, where:
- Line 1 is the Promoter range (traditionally 9-10)
- Line 2 is the Detractor range (traditionally 0-6 or 1-6)
- Line 3 is the full scale (traditionally 1-10 or 0-10).
For example, to define a traditional, 11-point NPS:
To calculate NPS for a 5 point scale:
Top Box
A Top Box is the ratio some segments represent within the set of all segments. This calculation most often refers to the percentage the highest ratings represent within the set of all ratings, usually the 9's and 10’s in a 10-point rating scale (which is specifically known as a Top 2 Box).
The Calculation property defines the score to use in the calculation. Specifically, the property has two lines:
- Line 1 is the range of scores in the subset.
- Line 2 is the range of scores in the whole set.
For example, for a Top 2 Box on an 11-point scale, the Calculation is the set of 9 and 10 scores divided by the set of 0 through 10 scores:
For a 5-point scale, the Top 2 Box Calculation is:
Top Box is not limited to the “top” scores. You could, for example, have a ratio of the bottom four scores in a 10-point scale, like this:
You can also determine the percentage of detractors within the set of passives and detractors:
For non-numeric scores, separate the scores with a pipe-character (|). For example, for Yes and No ratings, to get the Top Box of Yes answers:
Social Media 5pt scale over the right-side box in the MemberAlternativeSets property, and select Top box as the CalculationType. No Calculation formula is needed. Count
The Count of samples in the set. This type is built-in and requires no Calculation formula.
null, and therefore does not support use of the Hide Unanswered property in reports.Average
The Average value of the numeric values of the underlying alternative set of the samples in the set. This type is built-in and requires no Calculation formula. This calculation is used by default for roles that have no other assigned calculations.
Sum
The Sum value of the numeric values of the underlying alternative set of the samples in the set. This type is built-in and requires no Calculation formula.
% Yes on a Yes/No field
The ratio of Yes answers in a Yes/No field. This calculation type is similar to Top Box.
To use this type, the results field must be an alternative set whose Magic ID property value is YES_NO. Additionally, when showing the ratio of the count within the sample size, the count is of Yes answers.
Medallia Impact Index
Medallia Impact Index (MII), also known as Impact Score, uses a proprietary calculation to determine the impact of a Medallia Text Analytics topic on the company's main score.This calculation type has been replaced by Delta Impact and Scaled Delta Impact. Do not use MII for new programs.
Local %
Used with Text Analytics, Local % calculates the percentage count of responses for a child topic within its parent topic. For example, of all people who talk about Bathrooms, 20% of them talk about Towels. For more information, see Text Analytics.
Global %
Used with Text Analytics, Global % calculates the percentage count of responses for a topic within the entire data set. For example, of all guests, 3% of them talk about Towels. For more information, see Text Analytics.
Delta Impact and Scaled Delta Impact
Delta Impact calculations indicate how the results for a subset of values impacts the score of all results in a set. This calculation is used most often in Text Analytics to prioritize the areas with the greatest negative or positive impact for improvement or sharing of best practices. Scaled Delta Impact is the same as Delta Impact, except the result is multiplied by 100.
Delta Impact usually returns a value that is a small fraction, like 0.013. Scaled Delta Impact returns 1.3 for the same set. In general, you should the use Delta Impact when the score is based on a percentage (such as Top Box or NPS), and Scaled Delta Impact when the score is not based on a percentage (such as a 1–5 or 1–10 scale).
Usually, impact scores are calculated for subsets of 100 or more results. In this scenario, when there are fewer than 100 results Experience Cloud shows a dash (-) to indicate there are not enough results in the subset. You can, however, lower the minimum sample size required for valid subsets, as described in Configuring the impact score. For more information about how the impact score is calculated for Text Analytics reports, see Impact score.
Custom JavaScript
Custom JavaScript allows for more complex calculations than are available with the default calculation types. A custom calculation is written in JavaScript and has access to the Experience Cloud in-memory memory database (the In-Memory Analytics Engine) via a JavaScript object called the Cube. For more information, see JavaScript functions.
Top-2 Box example
The following custom JavaScript produces a weighted Top-2 Box by segment type, where each of the four segments is 25% of the total score:
calculate = function() {
var A_num, A_den, B_num, B_den, C_num, C_den, D_num, D_den;
// Get the count of all 'A' segments with a score of 10 or 9.
A_num = cube.cut('q_buyer_segments', 'A').value(['10','9']).count;
// Get the count of all 'A' segments with a score of 0-10.
A_den = cube.cut('q_buyer_segments','A').value(
['0','1','2','3','4','5','6','7','8','9','10']).count;
// Get the rest of the segments the same way.
B_num = cube.cut('q_buyer_segments', 'B').value(['10','9']).count;
B_den = cube.cut('q_buyer_segments', 'B').value(
['0','1','2','3','4','5','6','7','8','9','10']).count;
C_num = cube.cut('q_buyer_segments', 'C').value(['10','9']).count;
C_den = cube.cut('q_buyer_segments', 'C').value(
['0','1','2','3','4','5','6','7','8','9','10']).count;
D_num = cube.cut('q_buyer_segments', 'D').value(['10','9']).count;
D_den = cube.cut('q_buyer_segments', 'D').value(
['0','1','2','3','4','5','6','7','8','9','10']).count;
// If any of the counts is zero (0) or null, return a null.
if (A_num!= 0 && A_num!= null && A_den!= null && B_num!= 0 && B_num!= null &&
B_den!= null && C_num!= 0 && C_num!= null && C_den!= null && D_num!= 0 &&
D_num!= null && D_den!= null)
{
return ((A_num/A_den*100)*.25 + (B_num/B_den*100)*.25 +
(C_num/C_den*100)*.25 + (D_num/D_den*100)*.25)
};
else return null;
}
calculate();
The return expression can be improved for performance with the following change:
return (((A_num/A_den)+(B_num/B_den)+(C_num/C_den)+(D_num/D_den))*25)
Satisfaction example
The following code produces %9-10 and %yes on satisfaction. (You would need to create additional calculations to account for yes/no alternatives.)
calculate = function() {
var A_num, A_den, B_num, B_den, C_num, C_den, D_num, D_den;
A_num = cube.cut('q_buyer_segments', 'A').value(['Yes']).count;
A_den = cube.cut('q_buyer_segments', 'A').value(['Yes','No']).count;
B_num = cube.cut('q_buyer_segments', 'B').value(['Yes']).count;
B_den = cube.cut('q_buyer_segments', 'B').value(['Yes','No']).count;
C_num = cube.cut('q_buyer_segments', 'C').value(['Yes']).count;
C_den = cube.cut('q_buyer_segments', 'C').value(['Yes','No']).count;
D_num = cube.cut('q_buyer_segments', 'D').value(['Yes']).count;
D_den = cube.cut('q_buyer_segments', 'D').value(['Yes','No']).count;
if (A_num!= 0 && A_num!= null && A_den!= null && B_num!= 0 && B_num!= null && B_den!= null && C_num!= 0 && C_num!= null && C_den!= null && D_num!= 0 && D_num!= null && D_den!= null) return ((A_num/A_den*100)*.25 + (B_num/B_den*100)*.25 + (C_num/C_den*100)*.25 + (D_num/D_den*100)*.25);
else return null;
}
calculate();
!HideUnanswered doesn't work by default. Your code must test for no sample and return a null value, as in the following examples: -
cube.count == 0 ? null : cube.avg; - For Score:
cube.count == 0 ? null : 10*cube.avg; - For Responses:
cube.count == 0 ? null : cube.count;
An error occurred when executing the query. The error has been logged; please make a different selection.
org.mozilla.javascript.WrappedException: Wrapped java.lang.IllegalStateException:
No DataCube (typically happens if there is data dependent logic in the client code) for DataPoint This happens when a custom calculation tries to use the result of one cube calculation to control flow that leads to another cube calculation. The first time the cube calculation runs it uses placeholder data to assess the query it needs to assemble, and then runs a second time to actually calculate the result. The first run might not recognize the full scope of what needs to be queried since it is using placeholder data to assess an if/else result.
For example, the following calculation produces an error because the first run does not process cube.cut(C).count, and therefore does not query that information.
if (cube.cut(A).count > x) {
return cube.cut(B).count;
} else {
return cube.cut(C).count;
}If you encounter this error, change your JavaScript to run the cube operations before the control flows.
Weighted NPS and Weighted Top Box
Do not use the Weighted NPS and Weighted Top Box calculation types, which cause a significant degradation of performance. Instead, use NPS or Top Box and apply a WeightingScheme.
Properties
- Label
-
A unique label for the calculation, not exposed to users.
- Name
-
The name of the calculation, exposed to users in dropdowns.
- Priority
-
The order of the calculation in the list and in dropdowns, lesser numbers above greater numbers.
- Description
-
Internal notes about the calculation.
- ZeroDecimals
-
When checked, decimal places are not shown when presenting the results of the calculation.
- StandardCalcDropdown
-
When checked, the calculation is displayed in the standard Calculation dropdown. When configuring legacy reporting modules, do not enable this property for Text Analytics calculations. When configuring Medallia Alchemy Experience Reporting modules, enable this property for both standard and Text Analytics calculations.
- TextAnalytics
-
When checked, the calculation is displayed in legacy reporting in the Text Analytics Calculation dropdown, which itself can be turned on in custom reports by using
CALCULATION_TAin the XML. For more information, see Custom Module. - CompanyAggregate
-
When checked, designates the calculation as the main aggregate calculation (such as Average, NPS, or Top 2 box) for your company. You can assign only one calculation as the CompanyAggregate. Checking CompanyAggregate automatically un-checks the property for the calculation configured as the CompanyAggregate previously.
The calculation designated as the CompanyAggregate is associated with the
<company-aggregate/>element in custom reports, where you can use that element instead of defining the calculation explicitly. This element is useful for many Text Analytics reports, and allows for an easier transition for a company that has been traditionally focused on average scores if they move to NPS. In that scenario, you wouldn't have to change your custom report definitions, and would just change which calculation is the CompanyAggregate. The change will be updated in your reports immediately.Another important use case for the CompanyAggregate calculation is the Impact Score calculation. If your company is using traditional MII calculation, which is
(*avg*(topic)-*avg*(total))*num(topic)/(num(total)-num(topic))*100, your main aggregate should be Average. However, if you want to calculate impact on NPS or Top 2 box, you must set one of those calculations as the CompanyAggregate.Fo more information, see Impact score.
- CompanyImpact
-
When checked, designates the calculation as the main impact calculation. You can assign only one calculation as the CompanyImpact. Checking CompanyImpact automatically un-checks the property for the calculation configured as the CompanyImpact previously.
This provides an alternative to the traditional MII average calculation, applying that framework to NPS or Top-Box number instead of the average score. This is particularly useful for hospitality and NPS companies who do not use average as their key metric.
This calculation is also tied to the
<company-impact/>element in custom reports. Using this element ensures that you have flexibility to create multiple impact score calculation types while at the same time maintaining one main impact calculation that will be reflected in all reports (hardcoded or custom).Fo more information, see Impact score.
- UnsupportedInRanker
-
The calculation has no effect when selected in the Calculation dropdown of Ranker reports. The calculation appears in the dropdown, but when selected, the report displays Calculation unavailable.
- CalculationType
-
The type of calculation to perform. For more information, see the calculation types above.
- WeightingScheme
-
A weighting scheme to apply to the calculation results. Use this to balance results to better reflect their importance. Weighting applies only to Average, NPS, Top Box, and % Yes/No calculation types. For more information, see Weighting.
- Calculation
-
A text box to build a calculation formula. For many calculation types you do not need to build a calculation formula. If you enter a formula, it overrides the hard-coded formula of the calculation.
- MemberRoles
-
Choose the roles that have access to use the calculation by moving them to the right-side box.
- MemberAlternativeSets
-
Identifies alternative sets used in the computation which are not of the same scale as the main set(s). For example, when using an NPS calculation type, the main sets used for calculations should be in a 0-10 scale. However, if the fields to which the calculation is applied also include a 1-5 scale set, you must add that set here as an exception, and specify how that set maps to the main sets. When you include a set for exception, additional properties appear to define how to calculate the exception:
-
CalcTyp — The type of calculation to perform on this exception. Choose the same value as for the main CalculationType property.
-
Weighting Scheme — Do not use this property, which is underdevelopment and is reserved for future use.
-
JS — A custom calculation formula for this exception. Enter the same formula as for the main Calculation property.
To apply custom JavaScript to social, choose Social Media 5pt Scale in the MemberAlternativeSets section, and then select Custom JavaScript in the CalcType drop down. In the JS box enter JavaScript with this line first:
cube = cube.field('a_overall_score_with_social_media_5_buckets');. For example:cube = cube.field('a_overall_score_with_social_media_5_buckets'); var promoters = cube.value([5,4]).count; var detractors = cube.value([1,2,3]).count; var all = cube.value([1,2,3,4,5]).count; 100 * (promoters - detractors) / all; -
