Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello,
I have a system feeding over predicted revenue into PowerBI. The data is similar to this:
| Project ID | Metric | Value | Year |
| 1 | Revenue (Year 1) | 300000 | 2023 |
| 1 | Revenue (Year 3) | 650000 | 2025 |
| 1 | Revenue (Year 5) | 1000000 | 2027 |
| 2 | Revenue (Year 1) | 125000 | 2023 |
| 2 | Revenue (Year 3) | 275000 | 2025 |
| 2 | Revenue (Year 5) | 550000 | 2027 |
| 3 | Revenue (Year 1) | 50000 | 2024 |
| 3 | Revenue (Year 3) | 150000 | 2026 |
| 3 | Revenue (Year 5) | 300000 | 2028 |
| 4 | Revenue (Year 3) | 50000 | 2025 |
| 4 | Revenue (Year 5) | 100000 | 2027 |
| 5 | Revenue (Year 3) | 150000 | 2024 |
| 5 | Revenue (Year 5) | 330000 | 2026 |
| 6 | Revenue (Year 1) | 20000 | 2023 |
| 6 | Revenue (Year 3) | 50000 | 2025 |
| 6 | Revenue (Year 5) | 100000 | 2027 |
I am trying to run reports on the in-between years - Year 2 and Year 4 - using a formula of (((Year 3 + Year 1) / 2) + Year 1) for Year 2 and (((Year 5 + Year 3)/2) + Year 3) for Year 4. I created a metric to calcualte it, but my PowerBI reports rely on a calculated table to generate due to other (not included here) metrics. My desired result would be like this on my base table and then I would draw them into my calcualted table:
| Project ID | Metric | Value | Year |
| 1 | Revenue (Year 1) | 300000 | 2023 |
| 1 | Revenue (Year 2) | 475000 | 2024 |
| 1 | Revenue (Year 3) | 650000 | 2025 |
| 1 | Revenue (Year 4) | 825000 | 2026 |
| 1 | Revenue (Year 5) | 1000000 | 2027 |
| 2 | Revenue (Year 1) | 125000 | 2023 |
| 2 | Revenue (Year 2) | 200000 | 2024 |
| 2 | Revenue (Year 3) | 275000 | 2025 |
| 2 | Revenue (Year 4) | 412500 | 2026 |
| 2 | Revenue (Year 5) | 550000 | 2027 |
| 3 | Revenue (Year 1) | 50000 | 2024 |
| 3 | Revenue (Year 2) | 100000 | 2025 |
| 3 | Revenue (Year 3) | 150000 | 2026 |
| 3 | Revenue (Year 4) | 225000 | 2027 |
| 3 | Revenue (Year 5) | 300000 | 2028 |
| 4 | Revenue (Year 3) | 50000 | 2025 |
| 4 | Revenue (Year 4) | 75000 | 2026 |
| 4 | Revenue (Year 5) | 100000 | 2027 |
| 5 | Revenue (Year 3) | 150000 | 2024 |
| 5 | Revenue (Year 4) | 240000 | 2025 |
| 5 | Revenue (Year 5) | 330000 | 2026 |
| 6 | Revenue (Year 1) | 20000 | 2023 |
| 6 | Revenue (Year 2) | 35000 | 2024 |
| 6 | Revenue (Year 3) | 50000 | 2025 |
| 6 | Revenue (Year 4) | 75000 | 2025 |
| 6 | Revenue (Year 5) | 100000 | 2027 |
Is there a way in Power Query to generate these rows?
Solved! Go to Solution.
This is called "linear interpolation".
Borrowing the interpolation function from here:
Here's an example of how you can use it for your particular scenario:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hdIxDsMwCAXQq0SeGimDAeP0HN2qKEMGrx0qtedvTIciwKony3riA/K2JUhLurV3e7zadLm34znBfD5R7ue8YEZK+xJB6rDyD/IAcoeQVclVJMbZgGyyPZRsXNlkeyjZzDaa4mjlysBJMihYB5DtHq8CS1zRrdE7tUY9Cv9vsQzgt0Wys9R4OWi/hHfxKN5Fo+wf", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project ID" = _t, Metric = _t, Value = _t, Year = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Project ID", Int64.Type}, {"Metric", type text}, {"Value", type number}, {"Year", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Project ID"}, {{"Year", each {List.Min([Year])..List.Max([Year])}, type list}}),
#"Expanded Years" = Table.ExpandListColumn(#"Grouped Rows", "Year"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Years",{{"Year", Int64.Type}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type1", {"Project ID", "Year"}, #"Changed Type", {"Project ID", "Year"}, "Expanded Years", JoinKind.LeftOuter),
#"Expanded Expanded Years" = Table.ExpandTableColumn(#"Merged Queries", "Expanded Years", {"Value"}, {"Value"}),
#"Invoked Function" = fn_Interpolate(#"Expanded Expanded Years", "Year", "Value"),
#"Sorted Rows" = Table.Sort(#"Invoked Function", {{"Project ID", Order.Ascending}, {"Year", Order.Ascending}}),
#"Added Custom" = Table.AddColumn(#"Sorted Rows", "Metric", each "Revenue (Year " & Text.From([Year] - 2022) & ")", type text),
#"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Project ID", "Metric", "Value", "Year"})
in
#"Reordered Columns"
This is called "linear interpolation".
Borrowing the interpolation function from here:
Here's an example of how you can use it for your particular scenario:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hdIxDsMwCAXQq0SeGimDAeP0HN2qKEMGrx0qtedvTIciwKony3riA/K2JUhLurV3e7zadLm34znBfD5R7ue8YEZK+xJB6rDyD/IAcoeQVclVJMbZgGyyPZRsXNlkeyjZzDaa4mjlysBJMihYB5DtHq8CS1zRrdE7tUY9Cv9vsQzgt0Wys9R4OWi/hHfxKN5Fo+wf", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project ID" = _t, Metric = _t, Value = _t, Year = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Project ID", Int64.Type}, {"Metric", type text}, {"Value", type number}, {"Year", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Project ID"}, {{"Year", each {List.Min([Year])..List.Max([Year])}, type list}}),
#"Expanded Years" = Table.ExpandListColumn(#"Grouped Rows", "Year"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Years",{{"Year", Int64.Type}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type1", {"Project ID", "Year"}, #"Changed Type", {"Project ID", "Year"}, "Expanded Years", JoinKind.LeftOuter),
#"Expanded Expanded Years" = Table.ExpandTableColumn(#"Merged Queries", "Expanded Years", {"Value"}, {"Value"}),
#"Invoked Function" = fn_Interpolate(#"Expanded Expanded Years", "Year", "Value"),
#"Sorted Rows" = Table.Sort(#"Invoked Function", {{"Project ID", Order.Ascending}, {"Year", Order.Ascending}}),
#"Added Custom" = Table.AddColumn(#"Sorted Rows", "Metric", each "Revenue (Year " & Text.From([Year] - 2022) & ")", type text),
#"Reordered Columns" = Table.ReorderColumns(#"Added Custom",{"Project ID", "Metric", "Value", "Year"})
in
#"Reordered Columns"
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.