EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB36772: How to create a metric that computes the frequency of the Mode value of a metric for a particular attribute level


Stefan Zepeda

Salesforce Solutions Architect • Strategy


This article explains how to calculate how often the modal value of a metric occurs, at a particular level

 Strategy offers a Mode function out of the box, which allows the user to compute the mode of a particular metric or fact across a specific level.
In some situations, it is necessary for to compute the frequency of this mode, i.e., the number of occurrences of the mode value on the set of data.
There follows the procedure to create such a metric with an example in the Tutorial project.
The objective is to compute the frequency of the mode of the Units Sold metric. In this example, the Mode is to be computed over the Units Sold at Item level. However, the Mode and Frequency should be computed at report level.
 
The following report shows the units sold for articles in the Cameras Subcategory.
 

ka02R000000kXM4QAM_0EM440000002Dex.png

 
The Mode of Units Sold at Item level is 740, as there are two occurrences of this value. The expected result is that a report at subcategory level shows the Mode as 740, and the frequency as 2, as there are two items that sold this value, as shown below.
 

ka02R000000kXM4QAM_0EM440000002Dej.png

 
In order to create this metric,  follow the steps below 
1.- Create a metric Units Sold Item, whose level is modified to the lowest level at which the mode is to be computed, in this case Item.
 

ka02R000000kXM4QAM_0EM440000002Df1.png

 
2.- Create a Mode Units Sold metric, which computes the mode of the previous metric (not the fact!). The level is report level. This ensures that the Mode will be computed on Units Sold calculated at Item level.
 

ka02R000000kXM4QAM_0EM440000002Dez.png

 
 
 
3.- Create a Mode Frequency metric with formula
 
Sample Code/Error
Sum(IF(( = ), 1, 0)) {~}
 
 This metric will count the number of occurrences of the Mode at report level.
 

ka02R000000kXM4QAM_0EM440000002Dev.png

 
 
 
 


Comment

0 comments

Details

Knowledge Article

Published:

June 16, 2017

Last Updated:

June 16, 2017