The Lead function references a column and returns its values in offset positions, shifting the output up or down by a fixed number of rows.
The Lead function typically shifts values up, while the Lag function shifts values down. However, Sigma enables positive and negative offsets, allowing both functions to shift values in either direction.
Lead(value, [offset], [default])
- value (required) - the column of values to reference
- offset (optional) - the number of rows by which the output shifts the referenced values
- positive integers shift values up (above the reference)
- negative integers shift values down (below the reference)
- default (optional) - the value to return in the row that doesn't reference a column value (the last row in a positive offset or first row in a negative offset)
If the offset argument isn't specified, the output shifts values up one row. If the default argument isn't specified, the output returns "null."
A table lists the total attendance for each game of an MLB team's 2021 season. You can use the Lead function to compare this value with the number of attendees recorded for the next game.
Lead([Attendance], 1)The formula references the Attendance column and shifts its values up one row. The resulting output in each row of the Next Game column indicates the number of people who attended the game that occurred immediately after the one referenced in the Game Key column.