Power BI Connector for Alteryx : Get dataflows via SQL
Learn how to get dataflows using the Power BI Connector for Alteryx. This connector enables you to read and write Microsoft Power BI data effortlessly. Access, refresh, and manage datasets, reports, and dashboards — almost no coding required. We'll walk you through the exact setup.
Let's dive in!
Create data source using Power BI ODBC Driver
-
Download and install ODBC PowerPack (if you haven't already).
-
Search for
odbcand open the ODBC Data Sources (64-bit):
-
Create a User data source (User DSN) based on the ZappySys API Driver driver:
ZappySys API Driver
- Create and use a User DSN if the client application runs under a User Account. This is the ideal option at design time (e.g., when developing in Visual Studio). Use it for both types of applications (64-bit and 32-bit).
- Create and use a System DSN if the client application runs under a System Account (e.g., as a Windows Service). This is usually the required option in a production environment. If your Windows Service is a 32-bit application, you must use the 32-bit ODBC Data Source Administrator to configure this
-
When the Configuration window appears give your data source a name if you haven't done that already, then select "Power BI" from the list of Popular Connectors. If "Power BI" is not present in the list, then click "Search Online" and download it. Then set the path to the location where you downloaded it. Finally, click Continue >> to proceed with configuring the DSN:
PowerBiDSNPower BI
-
Now it's time to configure the Connection Manager. Select Authentication Type, e.g. Token Authentication. Then select API Base URL (in most cases, the default one is the right one). More info is available in the Authentication section.
Power BI authentication
Use delegated access (User Credentials) whenever you want to let a signed-in user work with their own resources or resources they can access. Whether it's an admin setting up policies for their entire organization or a user deleting an email in their inbox, all scenarios involving user actions should use delegated access. [API reference]
Follow these simple steps below to create Microsoft Entra ID application with delegated access:
WARNING: If you are planning to automate processes, we recommend that you use a Application Credentials authentication method. In case, you still need to use User Credentials, then make sure you use a system/generic account (e.g.automation@my-company.com). When you use a personal account which is tied to a specific employee profile and that employee leaves the company, the token may become invalid and any automated processes using that token will start to fail.- Navigate to the Azure Portal and log in using your credentials.
- Access Microsoft Entra ID.
-
Register a new application by going to App registrations and clicking on New registration button:
INFO: Find more information on how to register an application in Graph API reference. -
When configuration window opens, configure these fields:
-
Supported account type
- Use
Accounts in this organizational directory only, if you need access to data in your organization only.
- Use
-
Supported account type
-
Redirect URI:
- Set the type to
Public client/native (mobile & desktop). - Use
https://zappysys.com/oauthas the URL.
- Set the type to
-
After registering the app, copy the Application (client) ID for later:
-
Copy OAuth authorization endpoint (v2) & OAuth token endpoint (v2) URLs to use later in the configuration:
-
Now go to SSIS package or ODBC data source and use the copied values in User Credentials authentication configuration:
- In the Authorization URL field paste the OAuth authorization endpoint (v2) URL value you copied in the previous step.
- In the Token URL field paste the OAuth token endpoint (v2) URL value you copied in the previous step.
- In the Client ID field paste the Application (client) ID value you copied in the previous step.
-
In the Scope field use the default value or select individual scopes, e.g.:
-
offline_access -
https://analysis.windows.net/powerbi/api/Workspace.Read.All -
https://analysis.windows.net/powerbi/api/Dataset.Read.All -
https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All
-
- Press Generate Token button to generate Access and Refresh Tokens.
- Click Test Connection to confirm the connection is working.
- Optional step. Choose Default Workspace from the drop down menu.
- Choose Default Dataset from the drop down menu.
- Done! Now you are ready to use the API Connector!
API Connection Manager configuration
Just perform these simple steps to finish authentication configuration:
-
Set Authentication Type to
User Credentials [OAuth] - Optional step. Modify API Base URL if needed (in most cases default will work).
- Fill in all the required parameters and set optional parameters if needed.
- Press Generate Token button to generate the tokens.
- Finally, hit OK button:
PowerBiDSNPower BIUser Credentials [OAuth]https://api.powerbi.com/v1.0/myorgRequired Parameters Authorization URL Fill-in the parameter... Token URL Fill-in the parameter... Client ID Fill-in the parameter... Scope Fill-in the parameter... Default Dataset (select after generating tokens) Fill-in the parameter... Optional Parameters Client Secret Redirect URI (must match App Redirect URI) Default Workspace (Keep Empty for My Workspace - select after generating tokens) RetryMode RetryWhenStatusCodeMatch RetryStatusCodeList 429|503 RetryCountMax 20 RetryWaitTimeMs 1000 RetryMultiplyWaitTime True Login options
-
Then go to Preview tab to start building a SQL query.
-
Once you do that, proceed by opening Query Builder:
ZappySys API Driver - Power BIRead and write Microsoft Power BI data effortlessly. Access, refresh, and manage datasets, reports, and dashboards — almost no coding required.PowerBiDSN
-
Then simply select the Get Dataflows endpoint (action).
-
Continue by configuring the Required parameters. You can also set optional parameters too.
-
Move on by hitting Preview Data button to preview the results.
-
If you see the results you need, simply copy the generated query:
-
Click OK to use built SQL query and close the Query Builder.
-
Now hit Preview Data button to preview the data using the generated SQL query. If you are satisfied with the result, use this query in Alteryx:
ZappySys API Driver - Power BIRead and write Microsoft Power BI data effortlessly. Access, refresh, and manage datasets, reports, and dashboards — almost no coding required.PowerBiDSNSELECT * FROM Dataflows
You can also access data quickly from the tables dropdown by selecting <Select table>.AWHEREclause,LIMITkeyword will be performed on the client side, meaning that thewhole result set will be retrieved from the Power BI API first, and only then the filtering will be applied to the data. If possible, it is recommended to use parameters in Query Builder to filter the data on the server side (in Power BI servers).
Let's not stop here and explore SQL query examples, including how to use them in Stored Procedures and Views (virtual tables) in the next steps.
Power BI SQL query examples
Use these SQL queries in your Alteryx data source:
Read dataflows
Gets dataflows from the default workspace. To read from a specific workspace, supply WorkspaceId in the WITH clause.
SELECT *
FROM Dataflows
get_dataflows endpoint belongs to
Dataflows
table(s), and can therefore be used via those table(s).
Create SQL view in ODBC data source
ZappySys API Drivers support flexible Query language so you can override Default Properties you configured on Data Source such as URL, Body. This way you don't have to create multiple Data Sources if you like to read data from multiple EndPoints. However not every application support supplying custom SQL to driver so you can only select Table from list returned from driver.
If you're dealing with Microsoft Access and need to import data from an SQL query, it's important to note that Access doesn't allow direct import of SQL queries. Instead, you can create custom objects (Virtual Tables) to handle the import process.
Many applications like MS Access, Informatica Designer wont give you option to specify custom SQL when you import Objects. In such case Virtual Table is very useful. You can create many Virtual Tables on the same Data Source (e.g. If you have 50 URLs with slight variations you can create virtual tables with just URL as Parameter setting.
-
Go to Custom Objects Tab and Click on Add button and Select Add Table:
-
Enter the desired Table name and click on OK:
-
And it will open the New Query Window Click on Cancel to close that window and go to Custom Objects Tab.
-
Select the created table, Select Text Type AS SQL and write the your desired SQL Query and Save it and it will create the custom table in the ZappySys Driver:
Here is an example SQL query for ZappySys Driver. You can insert Placeholders also. Read more about placeholders here
SELECT "ShipCountry", "OrderID", "CustomerID", "EmployeeID", "OrderDate", "RequiredDate", "ShippedDate", "ShipVia", "Freight", "ShipName", "ShipAddress", "ShipCity", "ShipRegion", "ShipPostalCode" FROM "Orders" Where "ShipCountry"='USA'
-
That's it now go to Preview Tab and Execute your custom virtual table query. In this example it will extract the orders for the USA Shipping Country only:
SELECT * FROM "vt__usa_orders_only"
Get dataflows in Alteryx via SQL view
-
Open Alteryx Designer.
-
First, verify your DCM Settings to ensure you can access ODBC drivers. Go to Options > User Settings > Edit User Settings.
If DCM Mode is set to DCM Only, change it to DCM Optional if you would like to access the legacy Generic ODBC Connection.
After changing this setting, you may need to click Save and restart the connection window for the "Generic ODBC" icon to appear. -
Drag an Input Data tool onto your Alteryx canvas.
-
In the Configuration pane, click Set Up a Connection.
-
Note for DCM Users: If your environment has DCM (Data Connection Manager) enabled, the classic "Generic ODBC" icon may be hidden. To find it, select Data sources on the left and type "ODBC" in the search bar.
-
Once the ODBC window opens, click Connect Asset and select your PowerBiDSN DSN from the list.
Ensure you have configured a 64-bit System DSN in the Windows ODBC Data Source Administrator before this step. -
After selecting your DSN, configure your SQL Query in the Input Data tool configuration:
-
To save your data, drag an Output Data tool and connect it to the Input Data tool.
-
Configure the Output Data tool to write to a CSV file:
-
Press Run (Ctrl+R) to execute the workflow. Verify the results in the Results Window at the bottom.
Advanced topics
Creating SQL stored procedures
You can create procedures to encapsulate custom logic and then only pass handful parameters rather than long SQL to execute your API call.
Steps to create Custom Stored Procedure in ZappySys Driver. You can insert Placeholders anywhere inside Procedure Body. Read more about placeholders here
-
Go to Custom Objects Tab and Click on Add button and Select Add Procedure:
-
Enter the desired Procedure name and click on OK:
-
Select the created Stored Procedure and write the your desired stored procedure and Save it and it will create the custom stored procedure in the ZappySys Driver. Here is an example stored procedure for ZappySys Driver. You can insert Placeholders anywhere inside Procedure Body. Read more about placeholders here
CREATE PROCEDURE [usp_get_orders] @fromdate = '<<yyyy-MM-dd,FUN_TODAY>>' AS SELECT * FROM Orders where OrderDate >= '<@fromdate>';
-
That's it now go to Preview Tab and Execute your Stored Procedure using Exec Command. In this example it will extract the orders from the date 1996-01-01:
Exec usp_get_orders '1996-01-01';
Conclusion
And there you have it — a complete guide on how to get dataflows in Alteryx without writing complex code. All of this was powered by Power BI ODBC Driver, which handled the REST API pagination and authentication for us automatically.
Download the trial now or ping us via chat if you have any questions or are looking for a specific feature (you can also reach out to us by submitting a ticket):
More actions supported by Power BI Connector
Got another use case in mind? We've documented the exact setups for a variety of essential Power BI operations directly in Alteryx, so you can skip the trial and error. Find your next step-by-step guide below:
- Create a Push Dataset
- Delete a Dataset
- Execute a DAX query
- Get a Dataset
- Get a Workspace
- Get Datasets
- Get Table Columns
- Get Table Rows
- Get Tables
- Get Workspaces
- Insert Rows into Push Dataset Table
- Refresh a Dataflow
- Refresh a Dataset
- Truncate a Push Dataset Table
- Make Generic REST API Request
- Make Generic REST API Request (Bulk Write)