The window functions perform calculations across a set of table rows that are somehow related to the current row.
Following is the list of Window functions supported in Wyn Enterprise:
Description
The AVGW function calculates the AVERAGE value for each column across a set of table rows.
Syntax
COUNTW(<table>,<expression> [,PARTITIONBY(<expression>[,[expression] [,...]])] [,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] )] [,(ROWS|RANGE)( ((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW) [,((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW)])])
Parameters
Return Value
A decimal number.
Example
AVGW ( 'DimProduct', 'DimProduct'[ListPrice], PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]), ROWS(1 PRECEDING , 2 FOLLOWING) )
The COUNTW function calculates the COUNT value for each column across a set of table rows
COUNTW ( 'DimProduct', 'DimProduct'[ListPrice], PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]), ROWS(1 PRECEDING , 2 FOLLOWING) )
The DENSERANKW function calculates the DENSE RANK value for each column across a set of table rows.
DENSERANKW(<table>[,PARTITIONBY(<expression>[,[expression] [,...]])] ,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] ))
A whole number.
DENSERANKW ( 'DimProduct', PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]) )
The FIRSTVALUEW function calculates the FIRST value for each column across a set of table rows.
FIRSTVALUEW(<table>,<expression> [,PARTITIONBY(<expression>[,[expression] [,...]])] ,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] ) [,(ROWS|RANGE)( ((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW) [,((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW)])])
The first value.
FIRSTVALUEW ( 'DimProduct', 'DimProduct'[ListPrice], PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]), ROWS(1 PRECEDING , 2 FOLLOWING) )
The LAGW function calculates the next value for each column across a set of table rows.
LAGW(<table>,<expression> [,PARTITIONBY(<expression>[,[expression] [,...]])] ,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] ))
The next value.
LAGW ( 'DimProduct', 'DimProduct'[ListPrice], PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]) )
The LEADW function calculates the previous value for each column across a set of table rows.
LEADW(<table>,<expression> [,PARTITIONBY(<expression>[,[expression] [,...]])] ,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] ))
The previous value.
LEADW ( 'DimProduct', 'DimProduct'[ListPrice], PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]) )
The MAXW function calculates the MAX value for each column across a set of table rows.
MAXW(<table>,<expression> [,PARTITIONBY(<expression>[,[expression] [,...]])] [,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] )] [,(ROWS|RANGE)( ((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW) [,((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW)])])
The largest value.
MAXW ( 'DimProduct', 'DimProduct'[ListPrice], PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]), ROWS(1 PRECEDING , 2 FOLLOWING) )
The MINW function calculates the MIN value for each column across a set of table rows.
MINW(<table>,<expression> [,PARTITIONBY(<expression>[,[expression] [,...]])] [,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] )] [,(ROWS|RANGE)( ((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW) [,((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW)])])
The smallest value.
MINW ( 'DimProduct', 'DimProduct'[ListPrice], PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]), ROWS(1 PRECEDING , 2 FOLLOWING) )
The RANKW function calculates the RANK value for each column across a set of table rows.
RANKW(<table>[,PARTITIONBY(<expression>[,[expression] [,...]])] ,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] ))
RANKW ( 'DimProduct', PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]) )
The ROWNUMBERW function calculates the ROW NUMBER for each column across a set of table rows.
ROWNUMBERW(<table>[,PARTITIONBY(<expression>[,[expression] [,...]])] ,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] ))
ROWNUMBERW ( 'DimProduct', PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]) )
The SUMW function calculates the SUM value for each column across a set of table rows.
SUMW(<table>,<expression> [,PARTITIONBY(<expression>[,[expression] [,...]])] [,ORDERBY(<expression> [(ASC|DESC)] [,<expression> [(ASC|DESC)] [,...] ] )] [,(ROWS|RANGE)( ((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW) [,((UNBOUNDED|<Number>) (PRECEDING|FOLLOWING) | CURRENT ROW)])])
SUMW ( 'DimProduct', 'DimProduct'[ListPrice], PARTITIONBY('DimProductCategory'[EnglishProductCategoryName]), ORDERBY('DimProduct'[ProductName]), ROWS(1 PRECEDING , 2 FOLLOWING) )