Daily DAX : Day 387 SAMPLEAXISWITHLOCALMINMAX

Power BI DAX Function: SAMPLEAXISWITHLOCALMINMAX

What is SAMPLEAXISWITHLOCALMINMAX?

This is an advanced DAX (Data Analysis Expressions) function in Power BI used for data sampling in visualizations. It helps reduce the number of data points in line charts with a continuous (numeric) X-axis, preventing overcrowding while preserving key trends. The function bins the X-axis into equal-sized groups and keeps local minimum and maximum values from each bin across multiple series (like different lines on a chart).

Note: This function is primarily internal to Power BI visuals and is undocumented for direct user use in most scenarios. It's volatile (results can vary) and not supported in DirectQuery for calculated columns or row-level security.

Syntax

SAMPLEAXISWITHLOCALMINMAX(
    , 
    , 
    , 
    , 
    [ [, ...] ], 
     
    [,  [, ] 
    [, ] 
    [, ]
)
        
  • Size: Number of rows to return (approximate).
  • Table: The table expression to sample from.
  • Axis: The column for the X-axis (numeric).
  • Measure: The Y-axis measure(s).
  • MinResolution: Minimum bin size.
  • Optional parameters for advanced series handling, resolutions, and iterations.

Parameters Breakdown

Parameter Type Description
Size Integer Target number of sampled rows.
Table Table Input table with data points.
Axis Column Numeric X-axis column.
Measure Measure Y-value measure(s) to evaluate.
MinResolution Integer Smallest allowed bin size on X-axis.

Other parameters are optional and used for fine-tuning dynamic series and performance.

Use Case

In Power BI line charts, large datasets (e.g., millions of rows over time or prices) can make visuals slow and cluttered. This function automatically samples data to ~1,000-5,000 points by:

  1. Dividing the X-axis into bins based on Size and MinResolution.
  2. For each bin, retaining points with local min/max Y-values per series.
  3. Ensuring the chart shows smooth trends without losing peaks/valleys.

Example Scenario: Plotting sales amount vs. unit price for thousands of products. Without sampling, the chart lags; with this function, it renders quickly while highlighting sales dips and spikes.

Sample DAX Query:

EVALUATE
SAMPLEAXISWITHLOCALMINMAX(
    10,  -- Target 10 points
    SELECTCOLUMNS(Sales, "x", [Unit Price], "y", [Sales Amount]),
    [x],
    [y],
    10   -- Min resolution
)
        

This returns a sampled table with up to 10 rows, binned by price and sampled by sales.


Comments

Popular posts from this blog

Daily DAX : Day 131 SELECTEDMEASURE

Daily DAX : Day 446 INFO.CSDLMETADATA

Daily DAX : Day 453 ENDOFWEEK