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>] … )
| Parameter | Type | Description |
|---|---|---|
table | Table | The rows to analyse: a table of the model or any table expression. |
key | Expression evaluated for each row | What names each row in the result, such as a product's name. |
name1 | Text | The first variable's name, a text in quotes. |
expression1 | Expression evaluated for each row | The first variable's number for each row. |
name2 | Text repeatable | The next variable's name; two or more variables in all. |
expression2 | Expression 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 inCALCULATE, 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] )
| Key | PC1 | PC2 | PC3 |
|---|---|---|---|
| Lettøl | -2.32876267870648 | 0.356311483995844 | 0.261367355111571 |
| Pils | -0.925816232363049 | -0.130574245033645 | -0.252304531938161 |
| Lager | -0.834909975283221 | -0.392436309052337 | -0.216493262546259 |
| Pale ale | 0.456417600383057 | 0.0277967926277887 | 0.103132064267975 |
| IPA | 1.92185291365374 | 0.621213718707058 | -0.148247568571239 |
| Stout | 1.71121837231596 | -0.482311441244709 | 0.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
| Key | PC1 | PC2 | PC3 |
|---|---|---|---|
| China | 10.7767294899917 | -3.05536082590306 | -0.991880168101532 |
| United States of America | 9.1432627894094 | 2.08105842173349 | 5.28028967351439 |
| India | 6.5043098159083 | -3.66597064309419 | -4.68940905170369 |
| Japan | 2.23204501858235 | 1.01263328690051 | 0.873228229474867 |
| Germany | 1.67331302995441 | 1.34652403491796 | 0.553062167082427 |