Downloads
Power Query MList: pick and buildIntermediate

List.Range

Returns a section of a list, starting at a position and running for a number of items.

Syntax
List.Range(list, offset, optional count)

Returns: A list with the chosen items, in order.

What it does

List.Range cuts out a middle section of a list. You give a starting position (counting from zero) and how many items to take. Use it to pull one quarter out of a twelve-month list, or a fixed block of rows from a report that repeats in sections.

Syntax and arguments

Example

A budget list holds twelve monthly amounts from January to December. The second quarter, April to June, is needed for a quarterly variance report.

let
    MonthlyBudget = {100, 105, 110, 120, 125, 130, 135, 140, 145, 150, 155, 160},
    SecondQuarter = List.Range(MonthlyBudget, 3, 3),
    QuarterTotal = List.Sum(SecondQuarter)
in
    QuarterTotal

Position 3 is April, the fourth item. Taking three items gives April, May and June: {120, 125, 130}, and the total is 375.

Example: a second, different use

Getting the rows after a header: List.Range(Lines, 1) returns everything from the second item onward, the same as List.Skip with 1.

Things to watch

In business terms

Quarter slices of a monthly budget, a block of periods for a comparison and the rows for one section of a long export are typical uses. Pair the slice with the period labels, so the report is clear about which months it covers.

Related functions

All Power Query M functions · View as Markdown · M basics