Excel Power Query - Appending Tables With Fields From Main Table Only - excel

Appending Tables in Power Query from same workbook
I've been trying to append two tables and to keep only the fields from the main table (take out the secondary fields that do not exist in the main table) by appending queries within the same workbook. Desired Result.
The only approach I can think of is appending queries using sources outside of the Excel workbook and utilizing a folder to combine files from (use main table as a sample file) and then append any additional queries to that.Alternative Solution/Cumbersome and requires additional files
However, I need to append queries internally from the same workbook without the need of saving separate files/workbooks in a folder.

Try
=Table.Combine({MainTable, Table.RemoveColumns(SecondaryTable,List.Difference(Table.ColumnNames(SecondaryTable),Table.ColumnNames(MainTable)))})
like in
let Source = Excel.CurrentWorkbook(){[Name="MainTableSource"]}[Content],
z=Table.Combine({Source, Table.RemoveColumns(SecondaryTable,List.Difference(Table.ColumnNames(SecondaryTable),Table.ColumnNames(Source)))})
in z

Related

how can I manually update some table values in an Excel data model table imported from csv with power query

I am using Excel power query to import csv files containing transactions from a directory. That way adding a new file to the directory automatically makes it available when refreshing the query/data model. I load the table from the csv files into the data model. I do some cleaning and data transformation in the query.
However, there are some things that I can't do in the query that loads the raw data.
There may be missing data that I need to enter manually (a column missing some values)
I may need to split a transaction/row into multiple transactions/rows to categorize the parts correctly
It seems like there should be a way to do this that allows me to make my changes and not have them overwritten when I refresh the query to import new transactions.
Currently I am experimenting with creating a column with a unique id for the transaction table as part of the query. Then creating an aux table in excel relating to the raw transactions by unique id. I then make my changes in the aux table. And finally, I create a new table that merges the raw transactions with the aux table to create the working transaction table. This does work for missing data, or incorrect values, but it still doesn't allow me to split a row into multiple rows.
I would welcome any suggestions or references.

How to search across multiple excels for values and summarize to one excel workbook

I have 1000 excel workbooks and I have to summarize data in one excel workbook. Each workbook consists of data of one property (id of property, region, market value etc.) In the summary workbook I want to insert in a column the id of property and automatically search across the file of workbooks and insert the value for its region, market value etc.
Thanks
I am going to first assume that there is some structure to the workbooks you are discussing, for example all market value workbooks are the same but only the data is different. it would also be great if they were in different folders and if they were named in a consistent way.
This is only an example with links to different content that will help solve your problem. Your question is too vague and does not provide me with specific enough information to provide exact solution.
Combining records.
https://www.youtube.com/watch?v=rSQwZ1d3b1g&list=PLrRPvpgDmw0m3ohSvgwoHvd0KO8QsQdiK&index=5&t=0s
Merge Records.
https://www.youtube.com/watch?v=8F7v6YvnsiY&list=PLrRPvpgDmw0m3ohSvgwoHvd0KO8QsQdiK&index=6
Pivot Table Slicer for summary reports.
https://www.youtube.com/watch?v=zgt7SdrYJqg
Your best bet would be to use the power query feature to combine data from workbooks inside a folder
From DATA TAB -> Select GET DATA drop down from Get & Transform ribbon -> From File -> From Folder.
You should be able to combine all the workbooks in folder If your problem is simple.
If each workbook has multiple pages of info and the pages differ then you will need to create a custom function in power query to handle this issue.
If workbooks are all in one folder then you will need to run power query multiple times per condition and use a filter with power query assuming that the files have some kind of organized naming convention.
Once you have combined files and cleaned up the data you should be able to combine the records.
You will do this using the power query feature merge feature.
From DATA TAB -> Select GET DATA drop down from Get & Transform ribbon -> Combine Queries -> Merge.
Once records are all merged you should be able to have your final table and use a pivot table to give you the option to select ID with filters or pivot table slicers so that you can have the summary report by ID going across all the workbooks like you wanted.
If anything is unclear please provide more info so i can help you specifically

Sharing Excel file containing Power Queries without also needing the other datasource workbooks

I have an Excel file that contains a few Power Queries from other local workbooks.
Is it possible to save the file in a way to include the actual data of the queries where my users wouldn't need to have the other local workbooks for it to work? Essentially, creating a snapshot in time?
If you mean raw data, it's not possible - Power Query queries don't keep external data. But, of course, you may save results of queries in various forms (flat tables, pivot tables, data model).

Consolidating multiple tables from different workbooks with same fields into one table using PowerPivot

I have about 100 workbooks with a table in each workbook. Each table contains the same fields, but with different data. I am looking for an efficient way to consolidate all these tables into one Table on one excel workbook using PowerPivot. Is this possible?
Your solution is with Power Query. You simply have to go to Data tab -> New Query -> From File -> From Folder, and select the folder which contains all your excel files.
From there, click on Edit and this will bring you to the Power Query interface, where you can join all the files together. This video is an excellent guide to achieving this. If done right you should have them all combined in minutes.
Once everything is combined in Power Query, you can easily load the data into Power Pivot.

Query database columns using Excel/csv data

I have a case where I need to read an Excel/csv/text file containing two columns (say colA and colB) of values (around 1000 rows). I need to query the database using values in colA. The query will return an XMLType into which the respective colB value needs to be inserted. I have the XML query and the insert working but I am stuck on what approach I should take to read the data, query and update it on the fly.
I have tried using external tables but realized that I don't have access to the server root to host the data file. I have also considered creating a temporary table to load the data to using SQL Loader or something similar and run the query/update within the tables. But that would need some formal overhead to go through. I would appreciate suggestions on the approach. Examples would be greatly helpful.
e.g.
text or Excel file:
ColA,ColB
abc,123
def,456
ghi,789
XMLTypeVal e.g.
<node1><node2><node3><colA></colA><colB></colB></node3></node2></node1>
UPDATE TableA SET XMLTypeVal
INSERTCHILDXML(XMLTypeVal,
'/node1/node2/node3', 'colBval',
XMLType('<colBval>123</colBval>'))
WHERE EXTRACTVALUE(TableA.XMLTypeVal, node1/node2/node3/ColA') = ('colAval');

Resources