Pick data from the most recent Month and replicate it in future months

hananak

Board Regular
Joined
Feb 10, 2022
Messages
110
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Dear All,

I need quick help from experts in Power Query.

Currently, I have 12 budget columns, each month I receive Budget data and the relevant columns are populated with the budgeted figures and for future months it remains blank.
What I want are the columns I have for future months where the data is not available to pick the data from the most recent month's budget data and populate the future months' columns.

Please see the picture I have uploaded that will help you to understand better, what I want to do.

The columns highlighted in Green mean the Actual Budget data and the one Highlighted in Yellow is the data picked from the most recent actual data available.

Your help would be really appreciated.

Thank you in advance.
 

Attachments

  • PQ Help.PNG
    PQ Help.PNG
    26.6 KB · Views: 20
Sure. You can use the following simplified version.

Note: Since the empty values are null instead of zero, there is no need to change data types for this portion. You can adjust the data types later if necessary.
In this version, the only constraint is the WTEB prefix for the adjacent month columns. It also doesn't matter how many Heading columns exist.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    LastNoBlank = Table.Last(Table.SelectRows(Record.ToTable(Source{0}), each [Value] <> null))[Name],
    Result = Table.FromRecords(
                    Table.TransformRows(Source,
                        (r) => Record.TransformFields(r,
                                List.Transform({2..12},
                                    (i) => {"WTEB" & Number.ToText(i), each if _ = null then Record.Field(r, LastNoBlank) else _}))))
in
    Result
 
Upvote 0
Solution

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Sure. You can use the following simplified version.

Note: Since the empty values are null instead of zero, there is no need to change data types for this portion. You can adjust the data types later if necessary.
In this version, the only constraint is the WTEB prefix for the adjacent month columns. It also doesn't matter how many Heading columns exist.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    LastNoBlank = Table.Last(Table.SelectRows(Record.ToTable(Source{0}), each [Value] <> null))[Name],
    Result = Table.FromRecords(
                    Table.TransformRows(Source,
                        (r) => Record.TransformFields(r,
                                List.Transform({2..12},
                                    (i) => {"WTEB" & Number.ToText(i), each if _ = null then Record.Field(r, LastNoBlank) else _}))))
in
    Result
Perfect. Thank you very much!

I really appreciate the time and effort you have put into resolving my query.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top