Created
February 1, 2024 19:32
-
-
Save cbaragao/bd0749cc7f3be8fbe496b36b2a715ee9 to your computer and use it in GitHub Desktop.
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
| (batch as number, total as number, base as number) => | |
| let | |
| batches = List.Generate( | |
| ()=>[ | |
| from = base, | |
| to = batch | |
| ], | |
| each [to] <= total, | |
| each [ | |
| from = [from]+batch, | |
| to = if base = 1 then [to] + batch else ([from]+(batch)*2)-1 | |
| ] | |
| ), | |
| to_table = Table.FromList(batches, Splitter.SplitByNothing(), null, null, ExtraValues.Error), | |
| expanded = Table.ExpandRecordColumn(to_table, "Column1", {"from", "to"}, {"from", "to"}), | |
| changed_type = Table.TransformColumnTypes(expanded,{{"from", Int64.Type}, {"to", Int64.Type}}), | |
| index = Table.AddIndexColumn(changed_type, "run", 1, 1, Int64.Type), | |
| reorder = Table.ReorderColumns(index,{"run", "from", "to"}) | |
| in | |
| reorder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment