Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I have a table in Excel / Power Query that has the following structure:
| PPC | LocationID | Cycle | Effective from | Effective until | Group | Value |
| A | 1 | Q1 | 2024-01-01 | 2024-04-01 | A1 | 135.540 |
| A | 1 | Q1 | 2024-01-01 | 2024-04-01 | A2 | 180.718 |
| A | 1 | Q1 | 2024-01-01 | 2024-04-01 | A3 | - |
| A | 1 | Q1 | 2024-01-01 | 2024-04-01 | A4 | 532.836 |
| A | 1 | Q1 | 2024-01-01 | 2024-04-01 | A5 | 232.353 |
| A | 2 | Q1 | 2024-01-01 | 2024-04-01 | A1 | 6.672 |
| A | 2 | Q1 | 2024-01-01 | 2024-04-01 | A2 | 8.896 |
| A | 2 | Q1 | 2024-01-01 | 2024-04-01 | A3 | 34.311 |
| A | 2 | Q1 | 2024-01-01 | 2024-04-01 | A4 | 58.821 |
| A | 2 | Q1 | 2024-01-01 | 2024-04-01 | A5 | 11.436 |
| A | 3 | Q1 | 2024-01-01 | 2024-04-01 | A1 | 4.707 |
| A | 3 | Q1 | 2024-01-01 | 2024-04-01 | A2 | 6.278 |
| A | 3 | Q1 | 2024-01-01 | 2024-04-01 | A3 | 24.213 |
| A | 3 | Q1 | 2024-01-01 | 2024-04-01 | A4 | 78.741 |
| A | 3 | Q1 | 2024-01-01 | 2024-04-01 | A5 | 8.070 |
| A | 1 | Q2 | 2024-04-08 | 2024-07-08 | A1 | 135.540 |
| A | 1 | Q2 | 2024-04-08 | 2024-07-08 | A2 | 180.718 |
| A | 1 | Q2 | 2024-04-08 | 2024-07-08 | A3 | - |
Now, I would like to have a table in the end that fills the same elements into the dates between the from and until date.
So, I would like to get the values extrapolated for the weeks between the effective from and until date.
See the expected result below:
| Article | Country | Quarter | Date | Group | Value |
| A | 1 | Q1 | 2024-01-01 | A1 | 135.540 |
| A | 1 | Q1 | 2024-01-01 | A2 | 180.718 |
| A | 1 | Q1 | 2024-01-01 | A3 | - |
| A | 1 | Q1 | 2024-01-01 | A4 | 532.836 |
| A | 1 | Q1 | 2024-01-01 | A5 | 232.353 |
| A | 1 | Q1 | 2024-01-08 | A1 | 135.540 |
| A | 1 | Q1 | 2024-01-08 | A2 | 180.718 |
| A | 1 | Q1 | 2024-01-08 | A3 | - |
| A | 1 | Q1 | 2024-01-08 | A4 | 532.836 |
| A | 1 | Q1 | 2024-01-08 | A5 | 232.353 |
| A | 1 | Q1 | 2024-01-15 | A1 | 135.540 |
| A | 1 | Q1 | 2024-01-15 | A2 | 180.718 |
| A | 1 | Q1 | 2024-01-15 | A3 | - |
| A | 1 | Q1 | 2024-01-15 | A4 | 532.836 |
| A | 1 | Q1 | 2024-01-15 | A5 | 232.353 |
How would you do that with Power Query?
If required, I have a calendar table with all the dates etc.
Hi @joshua1990
add column
List.Dates(
[Effective from],
Duration.Days([Effective until]-[Effective from])/7+1,
#duration(7,0,0,0)
)
then expand
Stéphane
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
comb = Table.CombineColumns(
Source,
{"Effective from", "Effective until"},
(w) => List.Generate(
() => w{0},
(x) => x <= w{1},
(x) => Date.AddDays(x, 7)
),
"Date"
),
result = Table.ExpandListColumn(comb, "Date")
in
result
then sort and/or rename columns to your liking
What is the transformation logic?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 5 | |
| 4 |