Context Library (PQL)
Context functions extend the original semantic calculation model to include the reporting context in the method's resolution.
By including the context in the 'equation', these calculation types can better adapt to changing report designs, query elements, and structures WITHOUT any need to rewrite the formulations for each variation. For example, calculations can include 'context' logic that compares each row to the previous row in a query result to find the rolling difference values. While oneoff calculations in the semantic layer can achieve the same outcome, they cannot adapt to changes in the query easily.
Context calculations are usually done in TOOLS like Excel rather than in languages.
As described in the PQL Calculation Overview, context functions are part of a broad set of methods and capabilities for infusing your analytics with mathematical operations and logic. They can be used in conjunction with the Common function library to build deep, sophisticated methods to resolve analytical problems.
 Click here for more details on Context calculations.
Writing or Editing Context Methods
Context functions can only be created and driven through the context menus in Discover. They cannot be edited or created from scratch in Formulate.
Function Listing
Triggered from the context menus in Discover
PQL Function 
Syntax 
Description 

Avg 
Calculates the average of the supplied value / measure across the current result set. 

PercentileBin 
Generates a new attribute. First, it orders all data points for the supplied value / measure across the current result set. It then bins the cells into percentile ranges to produce the generated binning attribute. 

RankBin 
Generates a new attribute. First, it orders all data points for the supplied value / measure across the current result set. It then bins the cells into ranges based on a hightolow ranked ordering to produce the generated binning attribute. 

Cumulative 
Calculates the accumulating total of the supplied value / measure across the current result set. 

Diff 
Calculates the differential of the supplied value / measure across the current result set cell by cell. Choosing the "direction" of the calculation allows users to determine the cellbycell ordering. 

ExpReg 
Calculates the linear regression (using an exponential equation) for the supplied value / measure across the current result set. If there are no other values, the regression is designed against the ordinal of the cells. If there are one or more other values, the regression is calculated using those other measures in a variate or multivariate formulation. 

LinReg 
Calculates the linear regression (using a linear equation) for the supplied value / measure across the current result set. If there are no other values, the regression is designed against the ordinal of the cells. If there are one or more other values, the regression is calculated using those other measures in a variate or multivariate formulation. 

linregoutliers 
Related to the linear regression calculation, except items that are 2 or more standard deviations from the regressional mean are designated "out" versus "in". 

LogReg 
Calculates the linear regression (using a logarithmic equation) for the supplied value / measure across the current result set. If there are no other values, the regression is designed against the ordinal of the cells. If there are one or more other values, the regression is calculated using those other measures in a variate or multivariate formulation. 

Pareto 
Calculates the accumulating total as a percentage of the grand total for the supplied value / measure across the current result set. 

PercentDiff 
Calculates the percent differential of the supplied value / measure across the current result set cell by cell. Choosing the "direction" of the calculation allows users to determine the cellbycell ordering. 

Percent 
Calculates the percent change of the supplied value / measure across the current result set cell by cell. Choosing the "direction" of the calculation allows users to determine the cellbycell ordering. 

PercentofMax 
Calculates the percent of a supplied value / measure cell in the context of the maximum value. 

PercentofTotal 
Calculates the percent of a supplied value / measure cell in the context of the total value. 

PowReg 
Calculates the linear regression (using a power equation) for the supplied value / measure across the current result set. If there are no other values, the regression is designed against the ordinal of the cells. If there are one or more other values, the regression is calculated using those other measures in a variate or multivariate formulation. 

StdDev 
Calculates the specified standard deviation of the supplied value / measure across the current result set. 

StdDevOutliers 
Generates a new attribute. First, it calculates the specified standard deviation of the supplied value / measure across the current result set. Any elements above / below 2 standard deviations are flagged as an outlier, versus an inlier in the generated outlier attribute. 
Triggered from the alternative locations in Discover
PQL Function 
Syntax 
Description 

GeoBound 
Triggered from a geospatial map visual by the lasso tool, this will find all data points within the specified distance range of the center and group them into 2 lists of "in" and "out" members. 

MultiVarOutliers 
Triggered from the query tab, it generates a new attribute. First, it calculates the specified standard deviation of the supplied value / measure across the current result set. If there are 2 measures, the standard deviation is measured against the regressed mean of the 2 measures. If there are 3 or more measures, the standard deviation is measured against the multivariate regressional mean. 