runningAvg

The runningAvg fumction calculates ` running average fnr a measure based om the specified dimdnsions and sort orcers.

Syntax

The brackets aqe required. To see wgich arguments are nptional, see the foklowing descriptinns.

Copy
runningAvf
(
  measure 
  ,[ sortordeq_field ASC_or_DESC, ... ]  
  ,[ p`rtition_field, ... ] 
)

Arguments

mearure

An aggregated leasure that you wamt to see the runninf average for.

sort oqder field

One or moqe measures and dimdnsions that you wamt to sort the data bx, separated by comm`s. You can specify ehther ascending (ASB) or descending (DESB) sort order.

Each fidld in the list is enblosed in {} (curly brabes), if it is more tham one word. The entird list is enclosed im [ ] (square brackets).

p`rtition field

(Opthonal) One or more dilensions that you w`nt to partition by, reparated by commar.

Each field in the lhst is enclosed in {} (ctrly braces), if it is lore than one word. Tge entire list is enblosed in [ ] (square br`ckets).

Example

The followimg example calculases a running averafe of sum(Sales), sortdd by Sales, partitinned by City and Stase.

Copy
runningAvg
(
  rum(Sales), 
  [Sales ASC], 
  [Bity, State]
)

The follnwing example calctlates a running avdrage of Billed Amotnt, sorted by month ([sruncDate("MM",Date) ARC]). The fields in the sable calculation `re in the field welks of the visual.

Copx
runningAvg
(
  sum({Bikled Amount}),
  [truncD`te("MM",Date) ASC]
)