# 範例 - Rolling 函式

• `ROLLINGSUM` - 計算現行列前後某一列數範圍的累計總和。請參閱 ROLLINGSUM 函式
• `ROLLINGAVERAGE` - 計算現行列前後某一列數範圍的累計平均值。請參閱 ROLLINGAVERAGE 函式
• `ROWNUMBER` - 依排序資料欄的指定，計算每一列的資料列編號。請參閱 ROWNUMBER 函式

DateSales
10/2/16200
10/9/16500
10/16/16350
10/23/16400
10/30/16190
11/6/16550
11/13/16610
11/20/16480
11/27/16660
12/4/16690
12/11/16810
12/18/16950
12/25/161020
1/1/17680

`window value:ROWNUMBER() order:Date`

`derive type:single value:MONTH(Date) as:'Month'`

`derive type:single value:(1 + FLOOR(((month-1)/3))) as:'QTR'`

`window value:ROWNUMBER() order:Date group:QTR`

`window value:ROWNUMBER() group:Month order:Date`

`window value: ROLLINGSUM(Sales, -1, 0) order: Date group:QTR`

`window value: ROUND(ROLLINGAVERAGE(Sales, -1, 0)) order: Date group:QTR`

`ROLLINGAVERAGE` 函式可以計算小數值，因此可內含於 `ROUND` 函式中來取得精簡值。重新命名此資料欄 `avgWeekByQuarter`

DateWOQSalesQTDavgWeekByQuarter
10/2/161200200200
10/9/162500700350
10/16/1633501050350
10/23/1644001450363
10/30/1651901640328
11/6/1665502190365
11/13/1676102800400
11/20/1684803280410
11/27/1696603940438
12/4/16106904630463
12/11/16118105440495
12/18/16129506390533
12/25/161310207410570
1/1/171680680680