OpenBI Docs Buy

PCA.SCORES OpenBI

Each row's place on the principal components.

Group: Many variables at once. OpenBI’s own: DAX has no function of this name.

Syntax

PCA.SCORES ( <table>, <key>, <name1>, <expression1>, <name2>, <expression2> [, <name3>, <expression3>] … )
ParameterTypeDescription
tableTableThe rows to analyse: a table of the model or any table expression.
keyExpression
evaluated for each row
What names each row in the result, such as a product's name.
name1TextThe first variable's name, a text in quotes.
expression1Expression
evaluated for each row
The first variable's number for each row.
name2Text
repeatable
The next variable's name; two or more variables in all.
expression2Expression
repeatable, evaluated for each row
The next variable's number for each row.

Returns

Table. A row for each row of the table that has every variable: Key, then PC1, PC2 … with where the row lies on each component.

Remarks

  • A score is the row's standardised values weighted by PCA.LOADINGS. Each component's scores have mean 0, and their variance is the component's eigenvalue.
  • Plot PC1 against PC2 to see the rows spread out by everything they are measured on: rows close together are alike.
  • Every variable is first put on one scale: how many standard deviations each row lies above or below that variable's mean. Liters and kroner then weigh alike, and a change of units changes nothing.
  • A row where any variable is blank is left out. A variable must be a number on every row (text is an error, even text that reads as a number), and one that is the same on every row is an error too.
  • An aggregate as a variable, such as SUM ( Sales[Liters] ), is the whole table's on every row and is refused as the same everywhere: use a measure, or wrap it in CALCULATE, so each row gets its own.

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

Where each beer lies

Lettøl is furthest down PC1, IPA furthest up.

EVALUATE
VAR Beers =
    DATATABLE (
        "Beer", STRING, "Strength", DOUBLE, "Bitterness", INTEGER, "Price", INTEGER,
        {
            { "Lettøl", 2.5, 15, 30 }, { "Pils", 4.7, 25, 38 }, { "Lager", 5.0, 22, 40 },
            { "Pale ale", 5.5, 40, 55 }, { "IPA", 6.5, 65, 64 }, { "Stout", 7.0, 45, 70 }
        }
    )
RETURN
    PCA.SCORES ( Beers, [Beer], "Strength", [Strength], "Bitterness", [Bitterness], "Price", [Price] )
KeyPC1PC2PC3
Lettøl-2.328762678706480.3563114839958440.261367355111571
Pils-0.925816232363049-0.130574245033645-0.252304531938161
Lager-0.834909975283221-0.392436309052337-0.216493262546259
Pale ale0.4564176003830570.02779679262778870.103132064267975
IPA1.921852913653740.621213718707058-0.148247568571239
Stout1.71121837231596-0.4823114412447090.252545943676113

The five largest countries on PC1

EVALUATE
TOPN (
    5,
    PCA.SCORES ( Countries, Countries[Country], "People", Countries[People], "GDP", Countries[GDP], "GDP per person", [GDP per person] ),
    [PC1], DESC
)
ORDER BY [PC1] DESC
KeyPC1PC2PC3
China10.7767294899917-3.05536082590306-0.991880168101532
United States of America9.14326278940942.081058421733495.28028967351439
India6.5043098159083-3.66597064309419-4.68940905170369
Japan2.232045018582351.012633286900510.873228229474867
Germany1.673313029954411.346524034917960.553062167082427

PCA.LOADINGS, PCA.COMPONENTS, UMAP, KMEANS.

Last updated · OpenBI Studio 0.3.74