OpenBI Docs Buy

CORREL.SPEARMAN OpenBI

The rank correlation between two expressions over a table's rows (Spearman's; ties share their average rank).

Group: Statistics. OpenBI’s own: DAX has no function of this name.

Syntax

CORREL.SPEARMAN ( <table>, <x>, <y> )
ParameterTypeDescription
tableTableThe rows to go through.
xExpression
evaluated for each row
The first number, worked out for each row.
yExpression
evaluated for each row
The second number, worked out for each row.

Returns

Number. The Spearman rank correlation between x and y, from −1 to 1.

Remarks

  • Each value is replaced by its rank among its own column's values, and Pearson's correlation of the ranks is the answer. Tied values share the mean of their ranks.
  • It is 1 whenever y always rises with x, however unevenly, and it is hardly moved by one extreme value.
  • Rows with a blank in x or y are left out; with fewer than two rows, or no variation, the result is BLANK.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

A steady rise that is not a line

y is x squared, with one very large last value: Pearson's coefficient is well below 1, Spearman's is exactly 1.

EVALUATE
VAR Pairs =
    DATATABLE (
        "x", INTEGER, "y", INTEGER,
        { { 1, 1 }, { 2, 4 }, { 3, 9 }, { 4, 16 }, { 5, 100 } }
    )
RETURN
    ROW (
        "Pearson", CORREL ( Pairs, [x], [y] ),
        "Spearman", CORREL.SPEARMAN ( Pairs, [x], [y] )
    )
PearsonSpearman
0.7952035738296031

Ties share their rank

The two grades of 2 both rank 1.5.

EVALUATE
VAR Marks =
    DATATABLE (
        "Score", INTEGER, "Grade", INTEGER,
        { { 1, 2 }, { 2, 2 }, { 3, 3 }, { 4, 5 }, { 5, 4 } }
    )
RETURN
    ROW ( "Spearman", CORREL.SPEARMAN ( Marks, [Score], [Grade] ) )
Spearman
0.872081599272381

Population and GDP by continent, both ways

EVALUATE
SUMMARIZECOLUMNS (
    Countries[Continent],
    "Pearson", CORREL ( Countries, Countries[People], Countries[GDP] ),
    "Spearman", CORREL.SPEARMAN ( Countries, Countries[People], Countries[GDP] )
)
ORDER BY Countries[Continent]
Countries[Continent]PearsonSpearman
Africa0.8208711222954250.799276018099548
Asia0.7817684271894450.753700277520814
Europe0.7929678306685490.838056680161943
North America0.9507650419910180.737874097007224
Oceania0.9484720704372850.75
South America0.9839899020778970.934065934065934

CORREL, RANKX, LINESTX.

Last updated · OpenBI Studio 0.3.74