OpenBI Docs Buy

SAMPLEAXISWITHLOCALMINMAX

A line chart's sample of a table: each bin's least and greatest values per series; past the size asked, Power BI Desktop's own bins may differ.

Group: Window and visual calculations. Compatible with DAX.

Syntax

SAMPLEAXISWITHLOCALMINMAX ( <Size>, <Table>, <Axis>, <Measure> [, <Measure>] …, <MinResolution> [, <DynamicSeries>] … [, <DynamicSeriesSelectionCriteria>] [, <DynamicSeriesSelectionOrder>] [, <MaxResolution>] [, <MaxDynamicSeries>] [, <MaxIterations>] )
ParameterTypeDescription
SizeWhole numberAbout how many rows to keep.
TableTableThe chart's points: one row per point.
AxisColumnThe column along the chart's horizontal axis: numbers or dates.
MeasureColumn
repeatable
A column of the values drawn: the sample keeps the rows with each bin's smallest and largest value.
MinResolutionWhole numberThe fewest points to keep for each series across the axis.
DynamicSeriesColumn
optional, repeatable
Columns that make the series, one line each.
DynamicSeriesSelectionCriteriaKeyword
optional
NONE or ALPHABETICAL: the order of the series when not all of them fit.
DynamicSeriesSelectionOrderKeyword
optional
ASC or DESC for that order.
MaxResolutionWhole number
optional
The most points to keep for each series.
MaxDynamicSeriesWhole number
optional
How many series to keep at most.
MaxIterationsWhole number
optional
How many tries at a bin width that brings the rows near Size.

Returns

Table. Rows of the table, in its own order: all of them, or a sample that keeps each bin's lowest and highest points.

Remarks

  • Power BI's line charts use it to thin out a long series of points without losing its peaks and dips. Report authors seldom write it by hand.
  • When the table has no more rows than Size, it comes back whole; a Size of 0 or less gives an empty table.
  • Otherwise the axis is cut into bins of equal width, and for each series the rows holding a bin's lowest and highest value are kept; the number of bins is tried until the rows come near Size.
  • Rows whose axis value is blank are left out of a sample.

Compared with DAX

Past Size rows, OpenBI's bins are its own: Power BI may keep other rows of the same table. Up to Size rows, both return the table whole.

Examples

Few enough rows: the whole table

EVALUATE
VAR Days =
    DATATABLE (
        "Day", INTEGER, "Liters", INTEGER,
        { { 1, 40 }, { 2, 55 }, { 3, 38 }, { 4, 61 }, { 5, 70 }, { 6, 52 }, { 7, 45 }, { 8, 66 } }
    )
RETURN
    SAMPLEAXISWITHLOCALMINMAX ( 10, Days, [Day], [Liters], 10 )
ORDER BY [Day]
DayLiters
140
255
338
461
570
652
745
866

Eight days thinned to four

Two bins, days 1 to 4 and 5 to 8: each keeps its lowest and its highest day.

EVALUATE
VAR Days =
    DATATABLE (
        "Day", INTEGER, "Liters", INTEGER,
        { { 1, 40 }, { 2, 55 }, { 3, 38 }, { 4, 61 }, { 5, 70 }, { 6, 52 }, { 7, 45 }, { 8, 66 } }
    )
RETURN
    SAMPLEAXISWITHLOCALMINMAX ( 4, Days, [Day], [Liters], 4 )
ORDER BY [Day]
DayLiters
338
461
570
745

Days 3 and 4 are the first bin's low and high, days 7 and 5 the second's.

SAMPLE, SAMPLECARTESIANPOINTSBYCOVER, TOPN.

Last updated · OpenBI Studio 0.3.74