Tutorials December 30, 2021 · 2 min read

Allocating amounts using lists in Power Query

Learn how to use Power Query lists to allocate amounts over time periods by splitting date ranges into individual rows.

Gregor Brunner Gregor Brunner
Allocating amounts using lists in Power Query

Lists can be a powerful feature in Power Query, particularly useful when you have a start and an end date and need to work with all dates between them.

Basic List Syntax

A list from 1 to 10 in Power Query uses the syntax {1..10}.

Allocating Amounts Over Time

When you have start and end dates along with an amount for a given period, you can split it across the timeframe using the list operator {}.

Step 1: Create a Custom Column

Use the following code in a custom column:

{Number.From([Start])..Number.From([End])}

This code converts your Start column (a date) to a number, then uses two dots (..) followed by the End column (also converted to a number). The entire expression is wrapped in {} brackets to create a list. For each row, this generates a list of all numbers between Start and End.

Step 2: Expand to New Rows

Expand the lists to create individual rows for each day (still represented as numbers). Then convert this column back into date format.

Step 3: Calculate Daily Amounts

Divide your yearly amount by 365 to generate daily amounts. The data now matches perfectly since you’ve created one row per day.

Practical Applications

There are endless use cases for this small but very powerful way of handling data in Power Query. You might need only the dates between two dates, or allocate an amount evenly over time.

Important Considerations

Downsides: This approach might generate millions of rows, especially with multiple columns. Consider the volume beforehand.

Alternative: DAX calculations may be more suitable in some cases, though Power Query is often the better solution for this type of data transformation.