Peek(field_name [, row_no [, table_name]])

Peek (running balances in the script) in Power BI

Peek reads a field from a row already loaded into the output table. It is used for running balances and for reading values into variables. Power Query has no row-by-row state, so use grouped list logic, a SQL window function upstream, or a DAX measure.

Partial / different approach Power Query SQL DAX

Short answer: For running totals in reports, use a measure (see RangeSum running totals). If it must be a stored column, compute it in SQL with SUM() OVER (...) or in Power Query with List.Generate per group. To read a single value, use a query that returns a scalar, such as List.Max(Table[Date]).

What it does in Qlik

Peek('Field', row, 'Table') reads from the output table. Row -1 (default) is the last loaded row, and 0 is the first. In a sorted LOAD ... RESIDENT ... ORDER BY, you can refer to the value just calculated for the previous row, for example the running balance. Peek is also how scripts move a value into a variable after loading.

Qlik example

Qlik script
Balances:
LOAD Account, TxDate, Amount,
     If(Account = Peek('Account'), Peek('Balance') + Amount, Amount) AS Balance
RESIDENT Transactions
ORDER BY Account, TxDate;

LET vMaxDate = Peek('MaxDate', 0, 'Dates');

Power BI equivalent

Power Query, per group

Power Query M
let
    Grouped = Table.Group(Transactions, {"Account"}, {{"Rows", each
        let
            t       = Table.Sort(_, {{"TxDate", Order.Ascending}}),
            amounts = List.Buffer(t[Amount]),
            running = List.Generate(
                        () => [i = 0, s = amounts{0}],
                        each [i] < List.Count(amounts),
                        each [i = [i] + 1, s = [s] + amounts{[i] + 1}],
                        each [s])
        in
            Table.FromColumns(Table.ToColumns(t) & {running}, Table.ColumnNames(t) & {"Balance"}),
        type table}}),
    Expanded = Table.ExpandTableColumn(Grouped, "Rows", {"TxDate", "Amount", "Balance"})
in
    Expanded

SQL upstream (usually best)

SQL
SELECT Account, TxDate, Amount,
       SUM(Amount) OVER (PARTITION BY Account ORDER BY TxDate, TxID
                         ROWS UNBOUNDED PRECEDING) AS Balance
FROM Transactions;

DAX calculated column

DAX
Balance =
VAR d = Transactions[TxDate]
RETURN
    CALCULATE ( SUM ( Transactions[Amount] ), ALLEXCEPT ( Transactions, Transactions[Account] ), Transactions[TxDate] <= d )

Gotchas and behaviour differences

  • Qlik's order is the row order of the load. The DAX and window versions need a unique sort key: with ties on TxDate, the DAX column adds all of that date's rows at once.
  • Running balances as stored columns are rarely needed in Power BI. A measure respects filters, and a stored column does not.
  • Peek vs Previous: Peek reads fields of the output table, including values calculated in this load (such as Balance). Previous reads the previous input record, so it can use source fields that are not loaded. Both skip records discarded by WHERE. See Previous.

Official documentation

Related pages

Spotted an error or a better pattern? QlikToDax is maintained by a working BI consultant; corrections are welcome via the About page. Last reviewed 2026-10-25.