> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://help.sigmacomputing.com/docs/window-functions/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server. # Window functions > Window functions perform operations across an entire table, table grouping (grouped rows), or defined window of rows. > **Info** > > These functions work best with aggregated data in a grouped table. For a video explanation of working with functions of this type, see [Getting started with functions and groupings in Sigma](https://www.sigmacomputing.com/resources/training-videos/table-grouping-and-functions). Window functions perform operations across an entire table, table grouping (grouped rows), or defined window of rows. Sigma supports [cumulative](#cumulative-window-functions), [moving](#moving-window-functions), [shifting](#shifting-window-functions), and [ranking](#ranking-window-functions) window functions. ### Cumulative window functions Cumulative window functions evaluate a specified column in a table or grouping and return the running total or cumulative value for all rows up to and including the current row. This differs from aggregate values that calculate a summary value for the entire table or grouping. | Function | Description | | ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | [CumulativeAvg](/docs/cumulativeavg) | Calculates the running average up to and including the current row. | | [CumulativeCorr](/docs/cumulativecorr) | Calculates the correlation coefficient between dependent and independent data columns up to and including the current row. | | [CumulativeCount](/docs/cumulativecount) | Counts the number of non-null values up to and including the current row. | | [CumeDist](/docs/cumedist) | Calculates the cumulative distribution of values relative to the current row value. | | [CumulativeMax](/docs/cumulativemax) | Returns the largest value up to and including the current row. | | [CumulativeMin](/docs/cumulativemin) | Returns the smallest value up to and including the current row. | | [CumulativeStdDev](/docs/cumulativestddev) | Calculates the standard deviation of values up to and including the current row. | | [CumulativeSum](/docs/cumulativesum) | Calculates the sum of values up to and including the current row. | | [CumulativeVariance](/docs/cumulativevariance) | Calculates the variance of a column up to and including the current row. | ### Moving window functions Moving window functions evaluate a specified column and return a value based on a defined window of rows that moves in relation to the current row. | | | | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [MovingAvg](/docs/movingavg) | Calculates the numerical average of a column within a moving window. | | [MovingCorr](/docs/movingcorr) | Calculates the correlation coefficient of two numerical columns within a moving window. See [Pearson (bivariate) correlation coefficient](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient) . | | [MovingCount](/docs/movingcount) | Counts the number of non-Null values in a moving window. | | [MovingMax](/docs/movingmax) | Finds the maximum value of a column within a moving window. | | [MovingMin](/docs/movingmin) | Finds the minimum value of a column within a moving window. | | [MovingStdDev](/docs/movingstddev) | Calculates the standard deviation of a column within a moving window. | | [MovingSum](/docs/movingsum) | Calculates the sum of a column in a moving window. | | [MovingVariance](/docs/movingvariance) | Calculates the statistical variance of a column in a moving window. | ### Shifting window functions Shifting window functions evaluate a specified column in a table or grouping and return the value from a row that shifts in relation to the current row. | | | | ---------------------------------- | ----------------------------------------------------------------------------------------- | | [FillDown](/docs/filldown) | Replaces all `null` values in a column or grouping with the closest prior non-null value. | | [First](/docs/first) | Returns the first row value of a column or grouping. | | [FirstNonNull](/docs/firstnonnull) | Returns the first non-null value from a column or grouping. | | [Lag](/docs/lag) | Returns the value from a preceding offset row in a column or grouping. | | [Last](/docs/last) | Returns the last row value in a column or grouping. | | [LastNonNull](/docs/lastnonnull) | Returns the last non-null value in a column or grouping. | | [Lead](/docs/lead) | Returns the value from a subsequent offset row in a column or grouping. | | [Nth](/docs/nth) | Returns the value from the nth row of a column or grouping. | ### Ranking window functions Ranking window functions evaluate a specified column in a table or grouping and assign a rank to each row. | | | | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | [Ntile](/docs/ntile) | Assigns the specified rank, in order, to the column rows of a column, approximately equal number of rows for each rank. | | [Rank](/docs/rank) | Assigns ranks to unique values in a column, from rank 1 onwards. Skips duplicate values. | | [RankDense](/docs/rankdense) | Assigns ranks to all values in a column, from rank 1 onwards. Assigns the same rank to duplicate values. | | [RankPercentile](/docs/rankpercentile) | Ranks the rows in the table by percentile. | | [RowNumber](/docs/rownumber) | Numbers the table rows, starting with 1. | | [VisibilityLimit](/docs/visibilitylimit) | Limits the values displayed in a column to the number of specified values according to an order calculated by another ranking function. | > Official documentation and guidance for using Sigma to build AI apps, dashboards, and agents on governed warehouse data. ## Docs - [CumulativeAvg](https://help.sigmacomputing.com/docs/cumulativeavg.md): Use the Sigma CumulativeAvg function to calculate the numerical average of the input column up to and including the current value. - [CumulativeCorr](https://help.sigmacomputing.com/docs/cumulativecorr.md): Use the Sigma CumulativeCorr function to calculate the correlation coefficient of the input column up to and including the current value. - [CumulativeCount](https://help.sigmacomputing.com/docs/cumulativecount.md): Use the Sigma CumulativeCount function to count the number of non-null values of a column, up and including the current row value. - [CumeDist](https://help.sigmacomputing.com/docs/cumedist.md): Use the Sigma CumeDist function to return the cumulative distribution of an input column. - [CumulativeMax](https://help.sigmacomputing.com/docs/cumulativemax.md): Use the Sigma CumulativeMax function to calculate the maximum of a column up to and including the current row value. - [CumulativeMin](https://help.sigmacomputing.com/docs/cumulativemin.md): Use the Sigma CumulativeMin function to identify the minimum value of a column up to and including the current row value. - [CumulativeStdDev](https://help.sigmacomputing.com/docs/cumulativestddev.md): Use the Sigma CumulativeStdDev function to calculate the standard deviation of a column up to and including the current row value. - [CumulativeSum](https://help.sigmacomputing.com/docs/cumulativesum.md): Use the Sigma CumulativeSum function to calculate the sum of the input column up to and including the current row value. - [CumulativeVariance](https://help.sigmacomputing.com/docs/cumulativevariance.md): Use the Sigma CumulativeVariance function to calculate the variance of a column up to and including the current row value. - [FillDown](https://help.sigmacomputing.com/docs/filldown.md): Use the Sigma FillDown function to replace all null values within a column with the closest, prior non-null value. - [First](https://help.sigmacomputing.com/docs/first.md): Use the Sigma First function to return the first value in a column for every row, based on the current table sort. - [FirstNonNull](https://help.sigmacomputing.com/docs/firstnonnull.md): Use the Sigma FirstNonNull function to return the first non-null value in a column or grouping. - [Lag](https://help.sigmacomputing.com/docs/lag.md): Use the Sigma Lag function to access data in preceding rows in the same result set, without having to join the table to itself. - [Last](https://help.sigmacomputing.com/docs/last.md): Use the Sigma Last function to return the last row value in a column. - [LastNonNull](https://help.sigmacomputing.com/docs/lastnonnull.md): Use the Sigma LastNotNull function to return the last non-Null value in a column or grouping. - [Lead](https://help.sigmacomputing.com/docs/lead.md): Use the Sigma Lead function to access data in subsequent rows in the same result set, without having to join the table to itself. - [MovingAvg](https://help.sigmacomputing.com/docs/movingavg.md): Use the Sigma MovingAvg function to calculate the average of values in a moving window with specified start and end boundaries. - [MovingCorr](https://help.sigmacomputing.com/docs/movingcorr.md): Use the Sigma MovingCorr function to calculate the Pearson correlation coefficient, also known as the bivariate correlation, of two numerical. - [MovingCount](https://help.sigmacomputing.com/docs/movingcount.md): Use the Sigma MovingCount function to count the number of non-null values within a column in a moving window. - [MovingMax](https://help.sigmacomputing.com/docs/movingmax.md): Use the Sigma MovingMax function to find the maximum value of a column within a moving window. - [MovingMin](https://help.sigmacomputing.com/docs/movingmin.md): Use the Sigma MovingMin function to find the minimum value of a column within a moving window. - [MovingStddev](https://help.sigmacomputing.com/docs/movingstddev.md): The MovingStddev finds the standard deviation of a column within a moving window. - [MovingSum](https://help.sigmacomputing.com/docs/movingsum.md): The MovingSum functions calculates the sum of a column in a moving window. - [MovingVariance](https://help.sigmacomputing.com/docs/movingvariance.md): Use the Sigma MovingVariance function to calculate the statistical variance of a column in a moving window. - [Nth](https://help.sigmacomputing.com/docs/nth.md): Use the Sigma Nth function to repeat the Nth value of the the given column for every row in a column. - [Ntile](https://help.sigmacomputing.com/docs/ntile.md): Use the Sigma Ntile function to assign the rows of a column to a given number of ranks. - [Rank](https://help.sigmacomputing.com/docs/rank.md): Use the Sigma Rank function to assign a rank to each value in the specified column. - [RankDense](https://help.sigmacomputing.com/docs/rankdense.md): Use the Sigma RankDense function to assign ranks to values in a specified column. - [RankPercentile](https://help.sigmacomputing.com/docs/rankpercentile.md): Use the Sigma RankPercentile function to calculate the relative standing of a value in comparison to other values in the same column or group. - [RowNumber](https://help.sigmacomputing.com/docs/rownumber.md): Use the Sigma RowNumber function to number the rows in the table using the input column. - [VisibilityLimit](https://help.sigmacomputing.com/docs/visibilitylimit.md): Use the Sigma VisibilityLimit function to limit the values displayed in a column to the number of specified values according to an order calculated.