Can you add data to a Power Query ?

KennethVH

New Member
Joined
Dec 27, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
From our accounting program I can do an export of order data. (order-ID, amount, invoice-ID) If the order is not yet invoiced then the invoi-ID is still blank.
I use power Query to clean upand sort the data. So far so good.

Now I want to add an extra column in excelTable/PowerQuery to INPUT the date when the order was approved (this field is not in the accounting program).

I have done this in the excelTable (after save & update) , he created an extra column at the end, to put in the aproval date
But when I get an updated export from the accounting (with old and new datalines/info), my approval date stays on the same row(it doesn't seem to be connected to the order-id ).

That way I think order 3 was approved while it was actualy another order .
Summary : Can you add data to a powerquery data set?
Maybe I'm doing it wrong or using the wrong tool, can anybody help ?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
it sounds like you need to merge the new export with the already existing dataset in your Excel table.
 
Upvote 0
It is not straightforward. This is the complete code (in one query) but you need to do this in two steps.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TableWithoutInput = Table.AddColumn(Source, "Remark", each null),
    TableWithInput =  Excel.CurrentWorkbook(){[Name="Table1_1"]}[Content],
    Merge = Table.NestedJoin(TableWithoutInput, {"a"}, TableWithInput, {"a"}, "Added Custom", JoinKind.LeftOuter),
    Expand = Table.ExpandTableColumn(Merge, "Added Custom", {"Remark"}, {"Remark.1"}),
    DelCol = Table.RemoveColumns(Expand,{"Remark"}),
    Result = Table.RenameColumns(DelCol,{{"Remark.1", "Remark"}})
in
 
   Result

Book1
ABCDEF
1ababRemark
21t1t
32y2ytest
43u3u
Sheet1


Take these tables as example to practice.
First run this part en load it.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TableWithoutInput = Table.AddColumn(Source, "Remark", each null)
in
   TableWithoutInput

Then open the query again and replace the code with the complete code I posted above (there has to be remarks column before you can refer to it).
Note that the query table is called "Table1_1" in my case. It is defined in this line.

Power Query:
TableWithInput =  Excel.CurrentWorkbook(){[Name="Table1_1"]}[Content]
 
Upvote 0
Solution
It is not straightforward. This is the complete code (in one query) but you need to do this in two steps.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TableWithoutInput = Table.AddColumn(Source, "Remark", each null),
    TableWithInput =  Excel.CurrentWorkbook(){[Name="Table1_1"]}[Content],
    Merge = Table.NestedJoin(TableWithoutInput, {"a"}, TableWithInput, {"a"}, "Added Custom", JoinKind.LeftOuter),
    Expand = Table.ExpandTableColumn(Merge, "Added Custom", {"Remark"}, {"Remark.1"}),
    DelCol = Table.RemoveColumns(Expand,{"Remark"}),
    Result = Table.RenameColumns(DelCol,{{"Remark.1", "Remark"}})
in
 
   Result

Book1
ABCDEF
1ababRemark
21t1t
32y2ytest
43u3u
Sheet1


Take these tables as example to practice.
First run this part en load it.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TableWithoutInput = Table.AddColumn(Source, "Remark", each null)
in
   TableWithoutInput

Then open the query again and replace the code with the complete code I posted above (there has to be remarks column before you can refer to it).
Note that the query table is called "Table1_1" in my case. It is defined in this line.

Power Query:
TableWithInput =  Excel.CurrentWorkbook(){[Name="Table1_1"]}[Content]
Sorry followed your steps, but I can't seem to get it working properly.

Before the merge the TablewithInput has a remark "test"
1703792854540.png

After the expand I schould see the "test" remark,but instead I see Null
1703792979390.png

So in the Result the Remarks are all empty.
 
Upvote 0
Have you exactly followed the steps? It really should work.

The blue table is the base table. The green table is the query table.

Run the first part on the blue table and load it. Add a testcomment and go to edit the query again. Then paste the complete code
 
Last edited:
Upvote 0
Have you exactly followed the steps? It really should work.

The blue table is the base table. The green table is the query table.

Run the first part on the blue table and load it. Add a testcomment and go to edit the query again. Then paste the complete code
I Got it to work when the query is on a second tab (default), but when I try to do it like you on D1 it doesn't work. Perhaps I schould checked some wrong radiobutton on the popup screen ?
1703795808534.png
 
Upvote 0
I Got it to work when the query is on a second tab (default), but when I try to do it like you on D1 it doesn't work. Perhaps I schould checked some wrong radiobutton on the popup screen ?
View attachment 104067
Ok, I think i'm not to check the checkbox saying Append the data to the model?
Unchecking it does the trick (y)

Now trying to fit it in my much larger table with grouped fields 😵‍💫
Thanks a lot for your help
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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