How to Calculate Rolling Maximums in Excel Using Advanced Functions
Question details
The user wants to evaluate rolling ranges and filter records based on local maximum values using advanced Excel functions like thunks, MAP, DROP, TAKE, and LAMBDA.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating centered rolling windows to find local maximums, either by sequential row positions or non-sequential dates, to filter out specific records from a large dataset.
- Observed behavior
- Needs an efficient functional approach to process centered rolling windows and extract local maximums without exclusively relying on row positions when dates might be missing.
Before utilizing advanced dynamic array functions, ensure your version of Excel supports modern functions like LET, LAMBDA, and FILTER. Additionally, verify whether your dataset contains continuous dates or if some are missing, as this determines whether you need a row-based or date-based window calculation.
Use LET and FILTER for a Row-Based Rolling Maximum
Construct a conventional array formula using the LET and FILTER functions to evaluate a centered window and retain rows that match the local maximum.
This method is highly efficient for large datasets where records are sequential and there are no missing periods. By nesting SEQUENCE and BYROW inside a LET function, you can evaluate multiple rows simultaneously without manual drag-down formulas.
Start your LET function by defining the variable 'n' for your window size (e.g., n=2 for two rows before and after the current row).
Use the SEQUENCE function to generate an index of all rows in your data, and another sequence to calculate the window offsets (from -n to +n).
Use the INDEX function to pull the actual values from your dataset based on the combined row and offset sequences.
Apply BYROW and LAMBDA to loop through each row's window array, using the MAX function to identify the highest value within that local range.
Wrap the logical condition (checking if the current row's value equals the window's maximum) inside the FILTER function to output only the records representing local maximums.

Calculate Date-Based Rolling Windows
Adjust the calculation logic to handle datasets with non-sequential or missing dates by using calendar day offsets instead of row numbers.
Use WPS Spreadsheet for Advanced Array Calculations
WPS Spreadsheet provides robust support for modern dynamic array functions, allowing you to seamlessly execute complex rolling maximum calculations and filter large datasets with ease.
- 1. Open your dataset: Launch WPS Spreadsheet and open the file containing the data you want to analyze.
- 2. Select the target cell: Click on the top-left cell where you want the filtered rolling maximum records to spill.
- 3. Input the dynamic array formula: Type out your advanced formula using LET, SEQUENCE, and FILTER functions to establish the rolling window logic.
- 4. Execute the formula: Press Enter. WPS Spreadsheet will calculate the local maximums and dynamically spill the filtered results into the adjacent cells.

Frequently Asked Questions
What is a rolling maximum calculation in Excel?
A rolling maximum evaluates a sliding window of data (such as a specific number of days or rows before and after a target point) to identify the highest value within that local subset. It is commonly used in time-series data analysis and financial modeling.
Why is my LAMBDA or LET function returning a #NAME? error?
The #NAME? error typically occurs if your version of Excel does not support modern dynamic array functions. LAMBDA, LET, and FILTER require a newer version like Microsoft 365, Excel 2021, or the latest version of WPS Office.
How do I handle missing dates in a rolling window calculation?
If your dataset is missing dates, do not use row-based offsets (like SEQUENCE to check the previous 2 rows). Instead, calculate the window mathematically by adding and subtracting the necessary number of calendar days directly to the target date, then filtering the dataset for values that fall within that date range.
What is the alternative to Excel formulas for massive datasets?
For extremely large datasets (e.g., millions of rows) where complex array formulas might slow down spreadsheet performance, it is recommended to use dedicated data analysis tools like Python with the pandas library, which features a highly optimized rolling().max() method for centered rolling windows.




