Tableau Funtion: WINDOW_AVG( )
Tableau Function: WINDOW_AVG( )
Category: Table Calculation Functions
What Is the Function?
Purpose of the Function
The WINDOW_AVG() function in Tableau is a table calculation that computes the average of values within a defined window of rows in a partition. Unlike RUNNING_AVG(), which accumulates from the first row to the current row, WINDOW_AVG() allows you to define a custom range (window) of rows over which the average is calculated.
In simple terms, WINDOW_AVG() answers:
“What is the average of values within this specific range?”
Type of Calculations It Performs
Table calculations
Window-based aggregations
Moving average calculations
Order-dependent analytics
WINDOW_AVG() is evaluated after aggregation and depends on partitioning, sorting, and compute direction.
Practical Use Cases
Creating moving averages
Smoothing time-series data
Calculating averages across fixed ranges (e.g., last 3 months)
Comparing row values to window-based benchmarks
Performing advanced statistical analysis within groups
WINDOW_AVG(expression, [start, end])
| Parameter | Type | Description |
|---|---|---|
| expression | Aggregate / table calculation | The numeric expression to average within the window. Must be aggregated in the view. |
| start (optional) | Integer | The starting row offset relative to the current row. |
| end (optional) | Integer | The ending row offset relative to the current row. |
How It Works?
Mathematical / Logical Principle
WINDOW_AVG() calculates:
WINDOW_AVG = SUM(values in window) / COUNT(values in window)
The window is defined relative to the current row using offsets.
Return Value
Data Type: Numeric (decimal)
Meaning:
Returns the average of the expression within the defined window
Can vary for each row depending on window boundaries
When Should We Use It?
Use WINDOW_AVG() when you need to:
Compute moving averages
Analyze short-term trends
Compare current values against nearby values
Create rolling performance benchmarks
Perform window-based smoothing
Basic Usage
Average across entire partition
WINDOW_AVG(SUM([Sales]))
Defaults to full partition if no offsets are specified
Column Usage
3-period moving average
WINDOW_AVG(SUM([Sales]), -2, 0)
Averages current row and previous two rows
Centered moving average
WINDOW_AVG(SUM([Sales]), -1, 1)
Averages previous, current, and next rows
Advanced Usage
Compare value to window average
SUM([Sales]) - WINDOW_AVG(SUM([Sales]), -2, 0)
Shows deviation from recent average
Dynamic window using parameters
WINDOW_AVG(SUM([Sales]), -[Window Size], 0)
Allows interactive window control
Tips and Tricks
Always verify Compute Using and partition direction
Use
FIRST()andLAST()for full partition controlBest used with ordered dimensions like Date
Incorrect sorting leads to incorrect window results
Windows exceeding partition size are automatically adjusted
Related Functions
Functions commonly used alongside or as alternatives to WINDOW_AVG():
RUNNING_AVG()WINDOW_SUM()WINDOW_MAX()WINDOW_MIN()LOOKUP()INDEX()
We’ve got plenty of resources to help you master Tableau functions. For more details, check out the official Tableau documentation. Or, if you’re ready for more practice, let’s dive into related functions and build your Tableau skills further!
If you’re ready to harness the full power of Tableau and elevate your data analytics capabilities, our expert Tableau consulting services are here to guide you. Whether you need support with building advanced calculated fields, creating dynamic visual dashboards, or optimizing your data sources for peak performance, our team of experienced Tableau consultants delivers customized solutions designed for your business needs. Visit our Tableau Consulting page to discover how we can help your organization turn data into impactful, insight-driven decisions.
It calculates the average of a measure within a defined window of rows.
WINDOW_AVG() averages over a custom range, while RUNNING_AVG() accumulates progressively.
Yes, it is commonly used to create moving averages.
Yes, it is evaluated after aggregation and depends on the view layout.
Tableau automatically adjusts the window to fit within the partition.