Tableau Funtion: WINDOW_MEDIAN( )
Tableau Function: WINDOW_MEDIAN( )
Category: Table Calculation Functions
What Is the Function?
Purpose of the Function
The WINDOW_MEDIAN() function in Tableau is a table calculation that returns the median (middle value) of an expression within a defined window of rows in a partition.
In simple terms, WINDOW_MEDIAN() answers:
“What is the middle value within this window?”
Unlike averages, the median is resistant to outliers and represents the central tendency of the data more robustly.
Type of Calculations
Table calculations
Window-based statistical analysis
Median calculations
Order-dependent analytics
It computes the statistical median across a defined window relative to the current row.
Practical Use Cases
Creating rolling medians
Reducing impact of outliers
Analyzing central trends in skewed data
Comparing current value to median benchmark
Performing robust performance analysis
WINDOW_MEDIAN(expression, [start, end])
| Parameter | Type | Description |
|---|---|---|
| expression | Aggregate / table calculation | Numeric expression for which the median is calculated. Must be aggregated. |
| start (optional) | Integer | Starting row offset relative to the current row. |
| end (optional) | Integer | Ending row offset relative to the current row. |
How It Works?
Mathematical / Logical Principle
Collect values within defined window
Sort values
Identify middle position
If nn is number of values:
If odd:
Median = Valuen+1/2
If even:
Return Value
Data Type: Numeric (Decimal)
Meaning:
Returns the median value within the specified window
Changes dynamically per row depending on window
If the number of values is:
Odd → Returns middle value
Even → Returns average of the two middle values
When Should We Use It?
Use WINDOW_MEDIAN() when you need to:
Analyze skewed data distributions
Reduce impact of extreme values
Create rolling median analysis
Compare values to central tendency
Build robust financial or operational metrics
Basic Usage
Full partition median
WINDOW_MEDIAN(SUM([Sales]))
Displays median sales value for entire partition
Column Usage
3-period rolling median
WINDOW_MEDIAN(SUM([Sales]), -2, 0)
Calculates median of current and previous two rows
Centered rolling median
WINDOW_MEDIAN(SUM([Sales]), -1, 1)
Median of previous, current, and next rows
Advanced Usage
Compare value to rolling median
SUM([Sales]) - WINDOW_MEDIAN(SUM([Sales]), -2, 0)
Shows deviation from rolling median
Highlight above/below median
IF SUM([Sales]) > WINDOW_MEDIAN(SUM([Sales]))
THEN "Above Median"
ELSE "Below Median"
END
Identifies relative performance
Tips and Tricks
Use with time-based sorting for rolling medians
Median is more stable than average for skewed data
Always verify Compute Using settings
Performance can degrade with very large windows
Window must contain at least one value
Related Functions
Functions commonly used alongside or as alternatives to WINDOW_MEDIAN():
MEDIAN()(aggregate function)WINDOW_AVG()WINDOW_SUM()WINDOW_PERCENTILE()RUNNING_AVG()WINDOW_VAR()
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 median value within a defined window of rows.
WINDOW_MEDIAN() returns the middle value, while WINDOW_AVG() returns the arithmetic mean.
Yes, by specifying row offsets.
Yes, sorting determines row order in the window.
Median is better for skewed data or when outliers are present.