Analyzing your Microsoft Exchange Account Data with Power Query

Analyzing your Microsoft Exchange Account Data with Power Query

Rate This
  • Comments 5

One of the interesting additions to the Power Query Preview December update is the ability to import data from Microsoft Exchange. In this blog post, Miguel Llopis (a Program Manager in the Power Query team) will walk us through the capabilities exposed by this new feature and show how you can easily do analytics on top of your Exchange account.

Connecting to Exchange using Power Query

If you have installed the latest Power Query Preview update you will be able to connect to Microsoft Exchange via the “From Other Sources” menu in the Power Query ribbon.

Connect to Microsoft Exchange via From Other Sources menu 

After selecting this option, you will be prompted for your Exchange account credentials. Once you provide credentials the Navigator side pane will show the list of items available in your Exchange account, including Mail, Calendar, People, Tasks and Meeting Requests. You can use the Navigator to preview and select one or more items from this list. The Navigator will then let you load these items directly into the workbook or apply some filters and transformations before loading.

Navigator side pane shows list of items available 

In this case, we will select “Mail” and click “Edit”, so we can apply filters and transformations to our query before downloading the Mail data from Exchange. The Query Editor will show us a preview of the Mail items in my account, where we can apply any table transformations available in Power Query just as we do with data coming from other sources like databases or files.

Query Editor displays preview

Analyzing emails sent directly “to me” per day

To showcase some of the possible analytics that we could build, we will create a query that returns the number of emails sent directly to me by day.

You can see how the first column in the table contains the Folder Path information for each Mail item. In this case, my Exchange account has a set of rules and it sends the items that contain my email address in the “To” line to a certain folder (“ToMe”). We can filter this column to only include items in this folder, by using the Filter menu in the column header. You will notice that, because I have too many items in the Inbox folder, the filter values list only displays “Inbox” initially, since the Query Editor only uses a sample of the data for preview and transformation purposes, but there is a way for us to load up to the top 1,000 distinct values in this column by using the “Load more” link at the bottom of the filter menu.

Load top distinct values using Load More link 

After loading more items, I can search for the “ToMe” folder and apply the desired filter.

 Search for the To Me folder

Note that even if you don’t have custom rules and a folder structure to organize your mail, you can also achieve the goal of filtering down to only include emails with a certain recipient in the To line by expanding the “ToRecipients” column in this table and filtering by email address.

Now that we have filtered down to only the items that we want to analyze, let’s apply some extra transformations so we are able to group these items by received date. Notice that the table contains a “DateTimeReceived” column that we can use. In this case, since we want to group just by received date and not date/time, we will need to change the type of the “DateTimeReceived” column to Date. In order to do that, we can select the column and use the Data Type menu in the ribbon to set the column type to Date.

 Select the column and use the Data Type menu

Let’s also rename this column to “Date Received”.

 Rename the column to Date Received

To simplify this table and filter out unnecessary columns for our analysis, we can remove all columns in the table except for the “Subject” and “Date Received” columns, and change the Load Settings at the bottom of the Query Settings pane so we load the resulting data directly into the Data Model and not to the worksheet.

 Simplify the table

Now we can click “Apply and Close” and the query will start evaluating. This evaluation may take some time, as in my case it will download over 35,000 rows of Exchange mail data.

 Query will start evaluating

Creating a Power View report

Once the query has finished downloading, we can use Power View to build a line chart that displays the count of items per date.

 Use Power View to build a line chart 

It doesn’t come as a surprise, but we can see how the volume of my incoming emails per day during the last year decreased during the holidays, such as Christmas and New Year, or during some other periods when I took time off work.

Results are displayed 

Sharing this query with others

In addition to visualizing this report, I could also share the query with other users using the Power BI for Office 365 Preview. I can share the query with everyone in my organization, but given that I don’t want to include a preview of the query (which contains email subjects), I can disable the preview as part of my sharing settings.

Share the query using Power BI for Office 365 preview 

After sharing the query, it will be easily discoverable for other users in my organization via Online Search, and they will be able to run the same analysis using their own Exchange account credentials.

Others may now run the same analysis using their own Exchange account credentials

Additional resources:

  • I can't get past the first step "Exchange account credentials". I'm prompted with Email/Password. In our organization we use Email/SmartCard. Does anyone have a solution for this? I don't see any options to authenticate with smart card.

  • I jave alsoproblem> I cannot obtain results even if my credentials are OK. Which version of Exchange is needed?

  • I also had a problem with credentials, ended up going around it by changing a few properties in Outlook 2013 account settings/proxy settings. Another example of visualizations built on top of Exchange data can be found here:

  • Is it possible to query against

    Also to others: I had issues connecting to Exchange using my real email address. But I changed the ".com" to ".org" since I knew that's the address my IT department uses for O365, and viola it worked for me.

  • Also had initial difficulties with getting past the authentication step. I solved it by changing the privacy level of the data source to 'private' after the connection attempt timed out. But after this first success I could change it back to whatever level and still refresh. Strange.

Page 1 of 1 (5 items)

Comments in this blog are open and monitored for each post for a period of one week after the posting date. If you have a specific question about a blog post that is older than one week, please submit your question via our Twitter handle @MSPowerBI