Jan 21 2021 01:26 PM - edited Jan 21 2021 01:49 PM
I transform and load a CSV file into an excel sheet using Power Query:
Column1 | Column2.1 | Column2.2 |
01.01.2021 | A | BC |
01.02.2021 | M | NO |
01.03.2021 | X | YZ |
Customer wants to maintain next column of this table ("My Col") manually:
Column1 | Column2.1 | Column2.2 | My col |
01.01.2021 | A | BC | A is first |
01.02.2021 | M | NO | M is second |
01.03.2021 | X | YZ | X is last |
So far so good. The problem is that the next day, the CSV file can come in different order of records. And after Data-Update all, the table is updated in the this new order, but the manual column remains in the original order. Then we have data mismatch:
Column1 | Column2.1 | Column2.2 | My col |
01.02.2021 | M | NO | A is first |
01.03.2021 | X | YZ | M is second |
01.01.2021 | A | BC | X is last |
What is the correct process of combining power query table columns with manually maintained columns?
Thank You!
Jan 22 2021 01:18 AM
Solution@Zdenek_Moravec Not too long ago, similar questions came up on this forum. Both were responded to by
Thought the technique to do this would come in handy but didn't think it was very straight-forward. So, I created some kind of tutorial for myself, writing the process down step-by-step. And it includes a working, tough very simple, example. See attached.
Jan 22 2021 02:24 PM - edited Jan 22 2021 02:25 PM
@Riny_van_Eekelen , I modified a bit, hope self-explainable
let
Source = Excel.CurrentWorkbook(){[Name="Source"]}[Content],
Source3 = Excel.CurrentWorkbook(){[Name="Source3"]}[Content],
SourceColumns = Table.ColumnNames(Source),
SourceColumns3 = Table.ColumnNames(Source3),
FirstTime = List.ContainsAll(SourceColumns, SourceColumns3),
Return = if FirstTime then Source else
Table.Join(
Source, SourceColumns,
Source3, SourceColumns
)
in
Return
Another table in your file.
Jan 22 2021 09:28 PM
@Sergei Baklan Nice!!
Jan 24 2021 11:51 PM
Hello @Riny_van_Eekelen and @Sergei Baklan
Your solutions are already an Excel University, but it is understandable and it really works
Thank You very much!
Zdenek Moravec
Cesky Krumlov, Czech Republic
Jan 25 2021 12:32 AM
@Zdenek_Moravec , glad to help
Mar 04 2022 12:00 PM
I am a bit of novice but am able to follow. In your example, both sources are existing tables. Is it possible to replicate this if the original source is a file in a folder?
Mar 04 2022 01:13 PM
@TdotnotbotThis relates to a rather old post and I believe it relates to connecting to one source and then adding information to it manually, and keep it synchronised with the original source data. It doesn't really matter where the original file sits. What exactly are you looking at?
May 02 2022 12:00 PM
Below is a sample of the code following what I believe to be step-for-step as per instructions. When files are added and refreshed to the source folder, the manually updated rows remain in the same position in the workbook. Thank you for any help you might offer. This is driving me insane.
May 02 2022 09:04 PM
@Tdotnotbot Difficult to diagnose without having a close look at the file. First, make sure that the added column is in fact part of the table you connect to in Source2. If it's just "hanging" on to the right-hand side without being part of the table it will certainly not work.
The only other thing that comes to mind is that "SequenceNumber" in both tables are not aligned/unique. Are you sure that, for instance, an item with SequenceNumber 1 in Source2 is in fact the same item with that number in the table resulting from the #"Remove duplicates" step?
Rather than working on big tables from combined files from a folder, can you get the technique to work on a single file? Easier to debug that way.