Comprehensive and Detailed Explanation From Exact Extract:
The requirement is to compare each quarter’s profit to the median profit over a rolling window of the last four quarters, including the current one. This is a classic use case for WINDOW_ table calculations in Tableau.
Tableau documentation explains:
WINDOW_MEDIAN( expression, start, end ) computes the median of the expression over a window of rows defined by start and end, which are offsets relative to the current row.
To create a rolling calculation that includes the current row and the three preceding rows, the window frame must span four rows ending at the current row.
Conceptually, the correct pattern is:
Current quarter’s profit: SUM([Profit])
Rolling four-quarter median: WINDOW_MEDIAN(SUM([Profit]), previous_3, current)
In actual Tableau syntax, that pattern is written with a frame that begins three rows before the current row and ends at the current row.
Among the options provided:
Options A and B use INDEX() or FIRST() as the start of the window, which creates frames anchored to either the first row or varying positions in the partition, not a consistent four-quarter trailing window.
Option D anchors the frame relative to LAST(), which makes the window depend on the final row in the partition, not a trailing four-quarter window for each bar.
Option C uses a fixed frame of four rows expressed as (3, 0) in the argument list. While, in exact Tableau syntax, a trailing 4-row frame is typically written with a negative start offset and zero as the end offset, this option is clearly intended to represent the frame “three rows back through the current row” and is therefore the only answer that matches the required rolling four-quarter window conceptually.
So, using a WINDOW_MEDIAN over a four-row frame ending at the current row, as shown in option C, is the intended solution for coloring each bar based on whether:
SUM([Profit]) > rolling_median_over_last_4_quarters
Tableau table calculation reference describing WINDOW_ functions and their start/end frame parameters.
Examples in Tableau help that use WINDOW_SUM or WINDOW_AVG with a frame spanning a fixed number of previous rows to compute rolling-window metrics.
Best practices for using WINDOW_MEDIAN to compute rolling medians over sliding time windows.