Forum Discussion
Muniz_Felipe
1 year agoFrequent Visitor
Crossjoin lists in Power Query
Hello! I have two lists: one with the months, from 1 to 12 and other with 5 years, from 2021 to 2025. My idea is to build a small table with all the months in one column and each row in the se...
- 1 year ago
I've just found out I can do that by using List.Repeat with one of my lists. For example, in the formula below I used List.Repeat to repeat the year list 12 times, one for each month. And then the function Table.FromColumns transformed my two lists into a table.
Now, if I expand the column2, I'll have my crossjoined lists in Power Query.
slorin
1 year agoSuper User
Hi Muniz_Felipe
Another solution with Table.Join
= Table.Join(Table.FromColumns({{1..12}}, {"Month"}), {}, Table.FromColumns({{2021..2025}}, {"Year"}), {})
Stéphane
Muniz_Felipe
1 year agoFrequent Visitor
Interesting! That's another cool solution for this in a very simple way. Thanks!