Power Query Appending and Filtering Multiple Files with Inconsistent Lines

hayesb26

New Member
Joined
Dec 7, 2021
Messages
3
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi All-

First time posting here, I was unable to find this answer in a quick search but my apologies if it's been posted. We've recently started getting into Power query to automate repetitive processes at work - incredible tool. I look forward to spending a lot of time learning here. I have run into an issue though -- we have a handful of files that contain the same data for different units. However, the data is not on the same row/column of the file in each case.

I have uploaded the source files and filtered to present only the rows I'd like to see, but now I cannot get the data to aggregate in the same rows/columns for each category. You can see in the screenshot below that the rows 1 & 3 and 2 & 4 are the same, but I cannot figure out an easy/effective way to get them into just two rows (or columns, I've tried transposing a bunch of ways). Any tips or ideas?

1638920647795.png
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Show us a mock up of what you want this data to look like. Suggest in each case (above and mock up) you use XL2BB so we don't have to recreate your data. See my signature
 
Upvote 0
Thanks - I appreciate the help. Here is what I've currently got:

Import File Testing 2.xlsx
BCDE
2PROFIT AND LOSS ACCOUNTPBT impactPROFIT AND LOSS ACCOUNTPBT impact
3
4YTD-8642397.43
5YTD2770118.47
6ADC Elim Reserves-227973.18
72020 BALANCES 31/12/2020-6885382.05Holiday pay accural EUG rev-49503.9
8ZLGAP-12593IBNR Elim-221968
9DCC W/H Cost Capitalisation-759348.47
10Write off Local Intang-23263.991Q tax0
11Writeoff Month Labcap-53136.382Q tax0
12Employee Accrual-7130003Q tax0
13Depreciation write off-58905.784Q tax0
14Elim Mgt Ch0ADC Elim0
15Writeoff Month Labcap 2021 ADJ0
16Retirement obligation552000Subtotal-9901190.98
17Amortisation989208.81
18Per EUG-9901190.98
191Q tax0
202Q tax0Unreconciled variance-1.18484E-08
213Q tax0
224Q tax0
23
24Subtotal-3434953.92
25
26Per FRG-3434953.92
27
28Unreconciled variance1.30706E-08
29
30
31
32FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsxFR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsxLG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsxLG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
GAAP-STAT Power Query


The 'Profit and Loss Account' columns 1 and 3 contain the same type data that I'd like to be in one column, but they have different names and types so I don't want them to combine/merge, I want them to basically list below each other. The corresponding $ amounts are in columns 1 and 4. Ideally I'd be able to get something like this:

Import File Testing 2.xlsx
BCD
35PROFIT AND LOSS ACCOUNTPBT impactEntity
36YTD2770118.47FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
37FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
382020 BALANCES 31/12/2020-6885382.05FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
39ZLGAP-12593FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
40FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
41Write off Local Intang-23263.99FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
42Writeoff Month Labcap-53136.38FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
43Employee Accrual-713000FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
44Depreciation write off-58905.78FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
45Elim Mgt Ch0FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
46Writeoff Month Labcap 2021 ADJ0FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
47Retirement obligation552000FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
48Amortisation989208.81FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
49FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
501Q tax0FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
512Q tax0FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
523Q tax0FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
534Q tax0FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
54FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
55Subtotal-3434953.92FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
56FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
57Per FRG-3434953.92FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
58FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
59Unreconciled variance1.30706E-08FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx
60YTD-8642397.43LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
61LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
62ADC Elim Reserves-227973.18LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
63Holiday pay accural EUG rev-49503.9LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
64IBNR Elim-221968LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
65DCC W/H Cost Capitalisation-759348.47LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
661Q tax0LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
672Q tax0LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
683Q tax0LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
694Q tax0LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
70ADC Elim0LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
71LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
72Subtotal-9901190.98LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
73LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
74Per EUG-9901190.98LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
75LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
76Unreconciled variance-1.18484E-08LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx
GAAP-STAT Power Query
 
Upvote 0
Power Query:
let
    Source = Table.Combine({Table1, Table2}),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.StartsWith([PROFIT AND LOSS ACCOUNT], "FR5") then [PROFIT AND LOSS ACCOUNT] else null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if Text.EndsWith([PROFIT AND LOSS ACCOUNT], "xlsx") then [PROFIT AND LOSS ACCOUNT] else null),
    #"Replaced Errors" = Table.ReplaceErrorValues(#"Added Custom1", {{"Custom.1", null}}),
    #"Filled Up" = Table.FillUp(#"Replaced Errors",{"Custom.1"}),
    #"Removed Columns" = Table.RemoveColumns(#"Filled Up",{"Custom"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([PBT impact] <> "FR5 Cross Check PL (FRG) P09.21 run 23.9.21.xlsx" and [PBT impact] <> "LG3 Cross Check P&L (MS5) P12 for cross check diffs.xlsx"))
in
    #"Filtered Rows"

Append each table to the other produces your expected results.
 
Upvote 0
I do not think I have the two data sources currently set up as separate tables. I basically imported a folder (the number of 'entity' files will vary each time) and filtered by the sheet name down to get the specific sheets for each, I'd want this query to scale up/down depending on the files that are in the folder.

Is the above able to accommodate that? Sorry like I said, I'm still new and have just done an introductory training and a handful of queries thus far.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,664
Members
449,045
Latest member
Marcus05

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