How to Detect Consecutive Peak-Dip-Peak Sequences in Excel
Question details
The user needs an Excel formula to identify and count specific data patterns consisting of a set of high values, followed by significantly lower values, and returning to high values.
- Product
- Excel
- Device & OS
- not provided
- Scenario
- Data analysis and pattern recognition involving thresholds and moving sequence windows.
- Observed behavior
- The user wants to extract the total count of patterns where 'X' consecutive values at or above a high threshold are followed by 'X' values lower by at least 'Z', followed by another 'X' high values.
Ensure your dataset is organized in a single continuous column or row, and dedicate specific cells to define your variable thresholds (run length X, high threshold, and dip difference Z) for easier formula management.
Use Dynamic Array Functions (LET, SEQUENCE, SUMPRODUCT)
This method allows you to define thresholds as variables and evaluate overlapping or distinct rolling windows of data efficiently in modern Excel versions.
Using dynamic arrays makes it possible to evaluate complex sequential logic without relying on VBA macros. By combining LET for variable definition, SEQUENCE for window offsets, and SUMPRODUCT for boolean logic arrays, you can evaluate the entire sequence dynamically.
Create reference cells for your parameters: set cell A1 for 'Run Length (X)', A2 for 'Upper Threshold', and A3 for 'Dip Difference (Z)'.
Locate the column containing your sequence values, for example, C2:C100.
Start your formula with the LET function to store these variables, keeping the main logic clean and readable.
Use the SEQUENCE function inside your formula to generate rolling data windows of size 3X (representing the Peak + Dip + Peak length).
Apply boolean logic arrays (e.g., peak_condition * dip_condition * peak_condition) wrapped in SUMPRODUCT to count how many windows match your exact peak-dip-peak criteria.
Use Helper Columns for Traditional Excel Versions
If your spreadsheet software does not support dynamic arrays, you can break the sequence logic into helper columns.
Analyze Complex Data Patterns Using WPS Office
WPS Spreadsheet fully supports advanced dynamic array functions like LET, SEQUENCE, and SUMPRODUCT, making it incredibly easy to detect complex peak-dip-peak patterns without needing heavy macros.
- 1. Open your dataset: Launch WPS Spreadsheet and open the file containing your data.
- 2. Define your variables: Enter your sequence variables (X length, high threshold, dip drop Z) into empty reference cells.
- 3. Input the dynamic formula: Select an output cell and input your dynamic array formula using LET and SUMPRODUCT to evaluate the data range.
- 4. Calculate the result: Press Enter to instantly view the calculated count of your peak-dip-peak sequences.

Frequently Asked Questions
Can I detect overlapping sequences or just distinct ones?
It depends on your formula structure. Using a rolling SEQUENCE offset by 1 row will count overlapping patterns. To count distinct, non-overlapping sequences, you must offset the window by the total pattern length (3X) or filter the results.
Why does my LET formula return a #NAME? error?
The #NAME? error usually occurs if your version of Excel does not support the LET function (requires Microsoft 365 or Excel 2021) or if there is a typo in your defined variable names within the formula.
How do I handle missing or blank data points in the sequence?
You can modify your Boolean logic to use the ISNUMBER or ISBLANK functions, ensuring the formula ignores or appropriately flags empty cells before checking the threshold conditions against zero.




