Created
February 5, 2026 19:44
-
-
Save Medohh2120/9610b17648da284b174e43c961a85cdc to your computer and use it in GitHub Desktop.
Repeats a data range based on a frequency column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Name: REPEAT | |
| Recommended version: v2024 or 365 | |
| Description: Repeats a data range based on a frequency column. | |
| Optimized with Binary Search. | |
| Made By: Medohh2120 | |
| */ | |
| Repeat = LAMBDA(Values,Number_times, | |
| LET( | |
| RunTotal, SCAN(0, Number_times, LAMBDA(acc, nxt, acc + nxt)), //alternative: helper column or SUBTOTAL(9, OFFSET(Number_times, 0, 0, SEQUENCE(ROWS(Number_times)))), | |
| TotalRows, SUM(Number_times), | |
| RowMap, XLOOKUP(SEQUENCE(TotalRows), RunTotal, SEQUENCE(ROWS(Values)), , 1, 2), | |
| CHOOSEROWS(Values, RowMap) //alternative: INDEX(Values, RowMap, SEQUENCE(, COLUMNS(Values))) | |
| ) | |
| ); |
Author
Medohh2120
commented
Feb 5, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment