Simple List.Generate in Power Query: Master the 'Do Until Loop' Easily

preview_player
Показать описание
A simple example to learn how to use List.Generate for recursive calculations: We dive deep into the power of List.Generate in Power Query, using a fun Excel BI challenge to illustrate its automation capabilities. Watch as we repeatedly divide a number and round up the result, showcasing how List.Generate can handle tasks where the number of iterations is unknown. Plus, the task itself is simple, making it a great way to master List.Generate's capabilities in Power Query:

Divide the numbers given in column A by 7 and round it up.
Divide the result by 7 and round it up. Continue till you get 1.
Get the sum of all the numbers after roundup.

👉 List.Generate is a great function. ❤
👉 Once understood you can use if also for more complex tasks.

🔍 **What You'll Learn:** - Step-by-step instructions on using List.Generate - Tips and tricks to enhance your Power Query skills

#PowerQuery #Excel #PowerBI
Like 👍, comment 💬, and share with fellow data enthusiasts to spread the knowledge!

Ready to become a Power Query master? Join me, Matthias Friedmann, and learn advanced data techniques and solve complex Power Query challenges with ease:
Рекомендации по теме
Комментарии
Автор

Here is the code for you:
let
Source = Excel.CurrentWorkbook(){[Name = "Divide7"]}[Content],
#"Added Custom" = Table.AddColumn(
Source,
"Sum",
each List.Sum(
List.Generate(
() => [n = Number.RoundUp([Number] / 7)],
each [n] > 1,
each [n = Number.RoundUp([n] / 7)],
each [n]
)
) + 1
)
in
#"Added Custom"

MatthiasFriedmann