4 Ways to Export Data From Power BI

Updated on October 13, 2019
klanguedoc profile image

I have over 15 years experience in business intelligence. I currently work as a data engineer and data analyst and use Power BI daily.

Importing data into Power BI is easy using its data source connectors and custom data connectors. It is equally easy to export data from Power BI, either using the visual components, Power Query or R and Python. In this article, we will explore these different export options.

I will show you how to export data using the following methods:

  • Standard components
  • Copy Table
  • Using the R language
  • Using the Python language

I will use the following dataset https://data.world/finance/finances-of-selected-state but you are free to use any dataset that suits your purposes.

Before you can export data from Power BI, you need to enable this feature. Under Options in the File menu, select Report Settings and enable Exporting by choosing to allow user to export only summarized data or summarized and underlining data as in the screenshot below. For demonstration purposes, I will opt to export summarized and underlining data.

I will show you how to export data using the following methods:

  • Standard components
  • Copy Table
  • Using the R language
  • Using the Python language

I will use the following dataset https://data.world/finance/finances-of-selected-state but you are free to use any dataset that suits your purposes.

Before you can export data from Power BI, you need to enable this feature. Under Options in the File menu, select Report Settings and enable Exporting by choosing to allow user to export only summarized data or summarized and underlining data as in the screenshot below. For demonstration purposes, I will opt to export summarized and underlining data.

Source

Standard Components

This is the easiest. All standard components have a command to export data to the csv format. The command is available from the Focus mode button on each of the Standard Visualization components assuming you have enabled the option in the Options as I mentioned above. To demonstrate, I will import the dataset mentioned above using the Excel Data Source Connector.

If you are not familiar with importing data, follow these instructions:

  • From the ribbon menu, select Get Data
  • Then select the Excel connector (see image below)
  • Next, browse and select the dataset file
  • Finally, select the sheet Name

Excel Data Connector
Excel Data Connector

We will use the Table component (see image below) from the Standard Component palette for this example but this option is available in all Standard Visualizations.

Table component
Table component

Add fields to the table

From the list of fields on the right, add the fields that you want to export from the imported dataset. In the screenshot below, I selected all the fields from the imported dataset ( see the image below).

All fields added to Table component
All fields added to Table component

Click on the expansion button at the top as in the following screenshot (below) then the Export Data command. The data will be saved in csv format. You only need to select the location where you want to save the file.

Export Data option
Export Data option

There you have it.

Pros: It is fast and easy

Cons: There is a size limit of 30,000 records.

Copy Entire Table

Another option which eliminates the limitations from the first option is to use the “Copy Entire Table” option in the Power Query editor.

Copy Entire Table
Copy Entire Table
  1. Use the “Edit Queries” button to open the Power Query IDE
  2. Select the desired table if you have more than one
  3. From the dropdown button (see image above), select the “Copy Entire Table” command which will copy the entire contents to memory.
  4. Paste the contents into an Excel file

This is quick and easy unless your dataset is super large, then you may run into memory issues depending on the equipment you have. In which case, you will need to export the data directly to a csv file or another format like Excel, JSON or XML. I will demonstrate this option using both the R and Python languages.

Export Data using Python


Another great option to export data from Power BI is to use Python. The language is very powerful and has become the darling of the data science world. Using libraries like pandas, matplotlib, scikit-learn, numpy to name a few, allows a data scientist or a data analysis to perform very complex algorithms on data. Being a generalized language, Python has the same features as any other language including importing and export data which can be used with Power BI.

Before being able to use Python with Power BI, you need to download and install it. Use the latest version from the Python website. Opt for the 3.x platform version of the language it has better support for the newer versions of the libraries.

Configure Python in Power BI
Configure Python in Power BI

Configure Python in Power BI

Once the Python is installed, you need to head over to Power BI to configure the Python integration (see image above). Follow these steps:

  • Under Options in the File menu
  • Select the Options tab
  • Under the Global section, select the Python scripting menu item
  • Make sure both fields are filled out for the location of the Python 3 (32 or 64 bit depending on which version of Power BI you installed).
  • For the Detected Python IDE field, leave it at “Default OS program for .py files”

While using an IDE is easier to write and test your Python scripts, you can also write the Python script directly in Power BI. Follow these instructions:

  1. Click on “Edit Queries” to open the Power Query IDE
  2. On the far right, click on the “Run Python Script” button (see image below)
  3. Enter the script in the editor using the dataset as the input source
  4. The following code snippet will write the dataset to a csv file

Run Python script in Power Query editor
Run Python script in Power Query editor
d = pandas.DataFrame(dataset)

d.to_csv('C:/Users/kevin/Documents/export.csv', index=False)

You may need to install the Pandas Python library first which you can do with the following command using the Command Line editor (Windows) or Terminal (OSX/Linux/Unix):

Pip install pandas

In the above script, we use the DataFrame in pandas to define the dataset which is always represented by “dataset”. Next, we to the to csv function again from pandas to write the data to a location on your computer. The index flag is to omit using a row index when writing to the file. You also need to use forward slashes instead of the standard backslashes.

Once you run the script, the contents of "dataset" will be written to the file and location that you specified. Using the R option is very similar and actually requires even less code.

Export using the R language

Like the previous method, the R language has many powerful libraries and builtin functions for working with data. Again, like Python, you will need to download and install the R language before you can use it. But once installed you will need to configure it in Power BI (see image below). You can use an IDE like RStudio (separate install) or through Anaconda if you install it or, if your script is small, you can write directly in the Editor in Power BI

To export your data using R, open the Power Query editor using the “Edit Queries” button

Select the Run R Script button from the toolbar script as in image from the Transform tab

Configure R language in Power BI
Configure R language in Power BI
R script editor in Power BI
R script editor in Power BI

Add the following script to write the dataset to a csv file:

Write.csv(dataset, C:\\Users\\kevin\\Documents\\limonade.csv)

One line of code, simple. Again, the dataset represents the entire contents of the selected table if you have more than one. You can use back slashes provided you use the escape character. Or, you can use the forward slash.

Conclusion

You have seen four types of export options: using the export function from a visual component, but this has limitations on large datasets; the “Copy Entire Table” option which is quick and easy from the Power Query editor; For more complex operation you can use Python or R as well.

© 2019 Kevin Languedoc

Comments

    0 of 8192 characters used
    Post Comment

    No comments yet.

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, owlcation.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://owlcation.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)