Excel 2016- Load power query directly into power pivot - powerpivot

Is there a way to load power query data directly into power pivot without creating an excel table as an intermediary step?
All the examples I've found reference Excel 2010 and 2013. Although the instructions are similar, it does not work in 2016.
In following the steps found. when I go to "Existing Connections" in Power Pivot and try to open the Power Query connection. I get a message:
"The connection you’re trying to open was created with Power Query. To change this connection, use Power Query."
Is it possible to clean/transform data using power query and load it directly to power pivot in excel 2016?

I would go to the Data Ribbon and choose Show Queries. Depending on your Office/Excel update schedule, this may be changed to Queries & Connections. Either way, you are trying to open the Workbook Queries pane (appears on the right).
Within the Workbook Queries pane, right-click each Query and choose Load To. Ensure the first option is set to Only Create Connection, and that the Add this data to the Data Model option is checked.
With those options set, Load performance should be a lot faster, and you can exceed Excel's million row per table limit.

On the Excel Workbook Ribbon:
Option 1:
Go to: Power Pivot ↦ Add To Data Model
Option 2:
Go to Data ↦ Queries & Connections
right-click over the query you want to add to PowerPivot ↦ Edit
On the Power Query Editor: File ↦ Options & Settings ↦ Query Options ↦ Check Load to Data Model.
Finally: File ↦ Close & Load

Related

How to avoid running query twice - ODBC Excel (new query or editing existing query)

I have an ODBC connection to an AWS mysql database instance. It's extremely frustrating that it appears I'm obligated by the excel UI to run the query twice.
First, I have to run the query like this:
After this runs, which returns a limited amount of rows (2nd image below), then I have to run it again to load the data into excle.
My question is, is there any possible way to skip step 1 or step 2, so that I can input my query and have it load directly into the workbook?
I'm not understanding the problem. You are configuring a Query Connection. The first execution returns a preview and the "Transform data" option (if you want to further tailor the query). The second execution loads it. From that point on the query is set up. It only needs configured once.
To get new/changed data, you just need to do a "Refresh All" or configure it to automatically Refresh Data when the Excel Workbook is opened.
If you are adding a Query to many workbooks you could probably setup one then code a query substitution script.

Possible to load .SQL file to Power bi?

Just started exploring power bi and I came across a basic question that I find difficult to get a correct solution.
Is it possible to load .sql file in power bi and create a report for it? thanks
It is not possible to load a .SQL file in a Power BI report, but you can specify a SQL query when adding a data source, if you expand the Advanced Options:
If your query is complex you can create a stored procedure to wrap all of the code and then call the stored procedure from Power BI, e.g. EXEC NameOfYourStoredProcedure
I read the SQL as text file, add a custom column, pivot and adjust to be text combine with delimiter, drop excess column, and then go into advanced editor and make SQL database query.
Here is some code to put in advanced editor. Replace the bolded with your inputs:
let
Source = Table.FromColumns({Lines.FromBinary(File.Contents("**absolute_file_path.sql**"))}),
#"for pivot" = Table.AddColumn(Source, "Custom", each 1),
pivoted = Table.Group(#"for pivot", {"Custom"}, {{"Sql", each Text.Combine([Column1], "
"), type text}}),
#"SQL Query Readable" = pivoted{[Custom=1]}[Sql],
#"Output" = Sql.Database("**your-server.database.windows.net**", "**your-database-name**", [Query=#"SQL Query Readable"])
in
#"Output"
This way you do not need to go in and change the query content in the Power BI report. Nice if changing the file a lot because then you do not need to republish report every single time. Makes dataset depend on SQL in file and not SQL in query editor.
This probably has some security flaws and is more of a loophole, if file is formatted weird perhaps this could break? However the output is the same as if you do the method of copy and paste the query into the box as described in the other answer. The main draw of doing it this way is that it allows users to
not need to republish reports every time the SQL feeding the reports is updated.

UNION ALL with Excel file as data source

I have got the following Problem.
I have several Excel files containing each the data of a country in one folder.
However I want to pull that all into one Excel report.
As the content of the source files change dayly, I guess the best way to do that is to do a import via an SQL Statement using Union All.
However the problem is that MSQuery only allows me to Access one file at a time. Is there a Workaround for that problem?
Maybe create a data model and use DAX?
This sounds like a job for Power Query, a free add-in from Microsoft for Excel 2010 and Excel 2013, and built into Excel 2016 as "Get and Transform" in the Data ribbon.
You can create individual queries to the different Excel files in the different folder, then create a query that appends all previous queries into one table, which can be loaded to the Excel data model or a worksheet table for further processing.
The queries can be refreshed with a click when the data has changed.

Better way to export data from one database to another (SQLSever)

I'm importing a big flat file (about 400.000 rows and 255+ columns) into SQL Server Management Studio through the import wizard.
To get the right variables I use Suggest types, but I have found that I need to search through all the rows to get the right variable types. It takes a very long time. Is there a way to avoid this or do it faster?
Furthermore, my real goal is to transfer data from one sql server database to another on another computer. I do this by exporting it as a flat file. But maybe this is stupid since I lose the information about the correct format?
Thanks!
According to Copy one database to another database:
There are several ways to do this, below are two options:
Option 1
Right click on the database you want to copy
Choose 'Tasks' > 'Generate scripts'
'Select specific database objects'
Check 'Tables'
Mark 'Save to new query window'
Click 'Advanced'
Set 'Types of data to script' to 'Schema and data'
Next, Next
You can now run the generated query on the new database.
Option 2
Right click on the database you want to copy
'Tasks' > 'Export Data'
Next, Next
Choose the database to copy the tables to
Mark 'Copy data from one or more tables or views'
Choose the tables you want to copy
Finish
Backup your database and restores it on the other server (the tager server must be equal or higher version) or simply copy the database files to other server and attached it (when copying database files, you must ensures that either you have detached the database or stop the sql server service).

How can I change where Query results go in Excel VBA?

I have created a Query in Excel using the wizard and can successfully manipulate the query itself from VBA, but now I want to change where the results are displayed among multiple sheets. Is there a "method" built in to manipulate this?
You can record a macro of what you just did to create the query and then change the parameters you want in VBA. It should just be a matter of first selecting the cell where you want the results to land (prior to executing the query) "Range("A1").Select".
Once you have this code if you are still having problems changing the "target cells", edit this question and add the code.
If you created a query in Excel using the wizard, then it most-likely created a new connection in the workbook. If so, go to the worksheet you want the data to appear on again, then go to the Data tab -> Get External Data group -> Existing Connections -> Double-click the connection -> choose your option for data delivery (Table, PivotTable, PivotTable and PivotChart).