SAMPLECARTESIANPOINTSBYCOVER
A scatter chart's sample of a table: a row for each occupied cell of a grid; past the size asked, Power BI Desktop's own sample may differ.
Group: Window and visual calculations. Compatible with DAX.
Syntax
SAMPLECARTESIANPOINTSBYCOVER ( <Size>, <Table>, <XAxis>, <YAxis> [, <Radius>] [, <MaxMinRatio>] [, <MaxBlankRatio>] )
| Parameter | Type | Description |
|---|---|---|
Size | Whole number | About how many rows to keep. |
Table | Table | The chart's points: one row per point. |
XAxis | Column | The column of the points' horizontal position: numbers. |
YAxis | Column | The column of their vertical position: numbers. |
Radius | Column optional | A column of the points' sizes, for a bubble chart. |
MaxMinRatio | Number optional | Needed with a radius: how much larger the largest point is drawn than the smallest; more than 1. |
MaxBlankRatio | Number optional | Needed with a radius: how much larger the largest point is than one with no size; more than 1. |
Returns
Table. Rows of the table, in its own order: all of them, or one for each part of the chart that has points.
Remarks
- Power BI's scatter charts use it to keep a readable sample of many points: points drawn on top of each other add nothing, so one of them is enough.
- When the table has no more rows than Size, it comes back whole; a Size of 0 or less gives an empty table.
- Otherwise a grid is laid over the points' range and one row is kept for each cell that has points, the grid made finer or coarser until about Size cells are taken.
- Rows with a blank X or Y are left out of a sample.
Compared with DAX
Past Size rows, OpenBI's grid is its own: Power BI may keep other rows. A radius column is checked but does not change which rows it keeps.
Examples
Few enough rows: the whole table
EVALUATE
VAR Points =
DATATABLE (
"Product", STRING, "Price", DOUBLE, "Liters", INTEGER,
{ { "Pils", 38, 1004 }, { "IPA", 64, 332 }, { "Cider", 52, 301 }, { "Lettøl", 30, 169 } }
)
RETURN
SAMPLECARTESIANPOINTSBYCOVER ( 100, Points, [Price], [Liters] )
| Product | Price | Liters |
|---|---|---|
| Pils | 38 | 1004 |
| IPA | 64 | 332 |
| Cider | 52 | 301 |
| Lettøl | 30 | 169 |
Points on top of each other
B lies almost on A, and D almost on C. Asked for four of six points, the sample keeps one of each pair.
EVALUATE
VAR Points =
DATATABLE (
"Point", STRING, "X", DOUBLE, "Y", DOUBLE,
{ { "A", 1, 1 }, { "B", 1.1, 1.1 }, { "C", 9, 9 }, { "D", 9.2, 9.1 }, { "E", 5, 5 }, { "F", 1, 9 } }
)
RETURN
SAMPLECARTESIANPOINTSBYCOVER ( 4, Points, [X], [Y] )
| Point | X | Y |
|---|---|---|
| A | 1 | 1 |
| C | 9 | 9 |
| E | 5 | 5 |
| F | 1 | 9 |