As IT professionals, we always have tasks to report on certain aspects of day to day operations. A common request for Exchange administrators is to provide information about the mailboxes in an Exchange Server or Exchange Online organization.

It’s simple enough to use PowerShell to export mailbox information from Exchange to a CSV file to read in Excel. But it is much easier to read a visual report with charts and diagrams. Executives and customers also prefer to read visual reports instead of just receiving raw data in a spreadsheet. One of the tools we can use to produce visually pleasing reports is Power BI.

Power BI is Microsoft’s business analytics service. We can use Power BI to present data in visual reports and dashboards that users can interact with. In this blog post we’ll look at how to use Power BI to build a dynamic dashboard for the CIO that presents Exchange mailbox information.

Collecting the Exchange Mailbox Data

To build the Power BI dashboard we will need to generate a dataset from our Exchange Server environment. For this purpose, I am going to use Paul Cunningham’s mailbox reporting script. The output of this script is a CSV file that is going to be used as the dataset for the Power BI dashboard.

Report data depends on your environment and metadata that you track in your Active Directory. For example, this demonstration will use data that includes the users’ title, department, and office location. If you don’t have those fields populated in your Active Directory you will see different results. For testing purposes, you could add the data to the CSV file manually.

Connecting Power BI to the Dataset

To start building the dashboard we will need to download the authoring tool called Power BI Desktop. You can download it for free from the Microsoft website, and install it on your computer.

Launch Power BI Desktop and load your data. For this demonstration the data is the CSV file produced by the mailbox reporting script mentioned earlier.

How to Build a Dynamic Power BI Reporting Dashboard

Choose the Text/CSV option, and click Connect. A file explorer dialog box will appear so that you can select your CSV data file.

How to Build a Dynamic Power BI Reporting Dashboard

Power BI detects the data type of each column based on the first 200 rows of your dataset. In my example, . Using the entire dataset for data type detection means you are more likely to find errors in the data. However, the downside is that processing of very large datasets can be quite slow.

How to Build a Dynamic Power BI Reporting Dashboard

After completing data type detection, we have three options:

  • Load – Loads data to PowerBI Desktop for you to start creating dashboards.
  • Edit – Allows to perform data manipulations such as adding new columns, merging columns, changing data types and more. If you are familiar with Microsoft Excel column operations, this task will be very familiar to you.
  • Cancel – Takes you back to the main canvas.

I am going to click Edit to shape the dataset based on the business requirements. First, I will remove unnecessary columns from the dataset. Select any columns that you do not want to use in your dataset and click Remove Column.

How to Build a Dynamic Power BI Reporting Dashboard

Power BI Desktop tracks all the changes that you apply to your dataset, which you can see in the right column of the screenshot above. This is a very convenient feature when you perform a lot of operations. You can also rename those operations to make it even more descriptive if you are planning to share the source Power BI Desktop (.pbix) file with someone else.

I see that there is a small problem with this dataset. The first row of this table is a column name. Let’s convert the first row of this table to an actual column name of the dataset. In the Home tab, click Use First Row as a column option.

How to Build a Dynamic Power BI Reporting Dashboard

Next, I am going to change the data type of the columns that I am going to be using on my dashboard. To identify if Power BI Desktop recognized the column’s data type correctly, look at the symbol next to the name of the column.

How to Build a Dynamic Power BI Reporting Dashboard

For example, we can see that Department and Office columns are identified correctly, but Total Mailbox Size (MB) is not. I am going to change the datatype of Total Mailbox Size (MB) column from text to whole number. Choose the column, click on Transform and then in the Data Type drop-down select Whole Number.

How to Build a Dynamic Power BI Reporting Dashboard

My exchange environment consists of multiple domains, @contoso.com, @xyz.com, and @practical365.com. For this example, scenario the CIO wants to see a mailbox filter based on the domain. Unfortunately, the dataset file does not have a column for the user’s domain. I am going to solve this problem using the existing Primary Email Address column and one of my favorite Power BI Desktop features – Column From Example.

Navigate to Add Column tab and click the Column From Example option.

How to Build a Dynamic Power BI Reporting Dashboard

On the right side of your screen, you will see that Power BI Desktop created a new column. Now, we will need to configure this column to show only part of the Primary Email Address column text which is everything after @ symbol. To do that, I am going to click on the first row of this new column and type contoso.com and press enter key.

How to Build a Dynamic Power BI Reporting Dashboard

Power BI Desktop is smart enough to find a column in the dataset that matches specified criteria and populates data into the new field as required.

How to Build a Dynamic Power BI Reporting Dashboard

We can see that the domain name part of the Primary Email Address column was stripped and populated into our new column. For our convenience, let’s rename this column to Domain. To do that, right-click on the newly created column and select Rename and type Domain as a column name.

How to Build a Dynamic Power BI Reporting Dashboard

We are done shaping our data. Let’s navigate to Home tab and click on Close and Apply. Note: if you have a large dataset this operation may take some time.

How to Build a Dynamic Power BI Reporting Dashboard

If you ever need to go back and fix your dataset, navigate to Home tab and click on Edit Queries to return to query editor screen. Technically, you can replace your data source file, and Power BI will be able to run all these manipulations as long as file name and columns are the same.

Building a Dashboard Using Power BI Desktop

After completing data shaping steps, now we are going to design our dashboard.

First, I need to show a total number of mailboxes in my exchange environment. Drag the Card visualization to the canvas and select the column that you would like to perform the count operation on.

How to Build a Dynamic Power BI Reporting Dashboard

You can apply some design to the visual using the format tab on the visualization panel. Every visual has a different set of possible design options. For this demonstration I am just using manual formatting.

How to Build a Dynamic Power BI Reporting Dashboard

Next, let’s place a Pie Chart to show mailbox databases per server in the environment. To do that, turn on Pie Chart visualization, set legend to Primary Server/DAG column and values to Primary Mailbox column.

How to Build a Dynamic Power BI Reporting Dashboard

As with the earlier example, I also applied some design changes via the Format tab to make it easier to read.

How to Build a Dynamic Power BI Reporting Dashboard

Next, let’s present mailbox count per database. I am going to use a Funnel visualization to demonstrate that. There are two main settings of this visualization:

  • Group – for this demonstration I’ll use the database name.
  • Values – for this demonstration I’ll use the count of mailboxes (count of Display Name).

How to Build a Dynamic Power BI Reporting Dashboard

Again I am applying some formatting actions to this visualization.

How to Build a Dynamic Power BI Reporting Dashboard

How to Build a Dynamic Power BI Reporting Dashboard

Also, it is important to see the number of mailboxes per location. To do that I am going to use a stacked bar chart where I will be displaying locations on the axis by counting mailboxes per location.

How to Build a Dynamic Power BI Reporting Dashboard

Let’s apply some formatting to this visualization to make it look better.

How to Build a Dynamic Power BI Reporting Dashboard

Lastly, let’s provide the dashboard users with the ability to filter data based on mailbox domains. I am going to bring a Slicer visualization to the dashboard and set the Domain field (which is the custom field that we built earlier in this article) as the filtering variable.

How to Build a Dynamic Power BI Reporting Dashboard

When you create multiple visualizations that are connected to the same data source or multiple data sources with the linked data columns, Power BI creates a relationship between visualizations which make dashboards dynamic.

Let’s look at the final version of our dashboard; I am going to demonstrate how dynamically we can analyze our data.

How to Build a Dynamic Power BI Reporting Dashboard

How to Build a Dynamic Power BI Reporting Dashboard

Sharing the Power BI Dashboard

There are multiple ways that you can share your Power BI dashboards. Microsoft provides detailed documentation on how to share and collaborate with Power BI in the following articles:

I am going to recommend a couple of easy and practical ways to share your reports

  • Share pbix file (static) – When you design your report a pbix file is created. Just save the file and share it with your colleagues as long as they have access to the dataset file (CSV, Excel, web table, etc). You can send it them in an email, or place it on a shared network drive where they can connect to it as a PowerBI data source.
  • Publish to the Power BI service – Office 365 licenses include free Power BI service subscription with limited functionality. An overview of the differences between Power BI free and Pro is available here.
  • Publish to Web – Publish to the web is one of the easiest and free ways to share your dashboard with external audience. Your dashboard needs to be published to Power BI service first (does not require Pro version), and then you will be able to generate HTML iframe code to embed on a web page.

For both of the publishing options your dataset file needs to be available online. A shared OneDrive folder, Office 365 Group, or a SharePoint Online document library would be suitable.

How to Build a Dynamic Power BI Reporting Dashboard

If you are planning to store your CSV file locally (on-premises) and publish your report to PowerBI service, you have to install the on-premises data gateway to give Power BI service access to your local dataset file.

For this demonstration I’m going to publish my report to the web. As a first step we will need to publish our dashboard to the service. In Power BI Desktop, click on the File tab, Publish and then Publish to Power BI. You will be prompted to authenticate to Office 365, and your account must have a PowerBI license (free or Pro) assigned to it.

How to Build a Dynamic Power BI Reporting Dashboard

Follow the Power BI publishing prompts to publish your report to the service.

How to Build a Dynamic Power BI Reporting Dashboard

After your report is published, navigate to https://powerbi.microsoft.com and sign in with your Office 365 credentials, or if you are logged in to your Office.com account, click on waffle menu and choose Power BI.

How to Build a Dynamic Power BI Reporting Dashboard

Open your report from My Workspace, click on File and then Publish to web.

How to Build a Dynamic Power BI Reporting Dashboard

Copy the generated code and paste it to any web page that is available for you to edit. You can use your intranet webpage such as a SharePoint Wiki page, WordPress blog post, etc. Another option is to send the direct URL via email. These two options do not require Office 365 authentication to view the dashboard.

How to Build a Dynamic Power BI Reporting Dashboard

Updating the Dataset

As we designed our Power BI report to bring our CSV file to live, we will need to make sure that the output file is always up to date. There are multiple ways that you can automate this process. I am going to take the easiest way to automate this process by creating a Windows scheduled task to run the mailbox reporting script every week.

First, I am going to modify the script by hardcoding some of the values. You will need to remove this part of the script which requires passing values:

How to Build a Dynamic Power BI Reporting Dashboard

Then you will need to hardcode your environment values to the script via variables. In my environment I needed to hardcode the $server and $myDir variables.

How to Build a Dynamic Power BI Reporting Dashboard

Make sure that the output file name is always the same since your Power BI report will be linked to that file as a data source. To do that remove this part of the code:

How to Build a Dynamic Power BI Reporting Dashboard

And replace with this line of the code:

How to Build a Dynamic Power BI Reporting Dashboard

After the PowerShell script is modified, let’s create a scheduled task to run the script weekly. On a server that has the Exchange management tools installed, create a new Windows task and set a trigger as shown below.

How to Build a Dynamic Power BI Reporting Dashboard

Then set the Action to run your PowerShell script, where the argument is the path to your script.

How to Build a Dynamic Power BI Reporting Dashboard

That is it; your report is going to be generated every week and Power BI services will be picking up file updates. You can either manually refresh data from Power BI Desktop or schedule automatic refreshes. To refresh data set via Power BI Desktop click More options on the right side of the panel and select Refresh Data.

How to Build a Dynamic Power BI Reporting Dashboard

To schedule a dataset refresh via Power BI service, log in to PowerBI service, navigate to Workspaces, Datasets and then click on Schedule refresh. Note that Power BI free allows manual refresh or schedule dataset refresh once a day, whereas Pro version allows to schedule it multiple times a day.

How to Build a Dynamic Power BI Reporting Dashboard

Summary

In this article I demonstrated how to use Power BI to connect to a dataset, create a reporting dashboard, and then publish that dashboard for users to access it. As you can see from this demonstration, Power BI is a great tool for turning raw data into visually interesting dashboards and makes it simple to create useful reports for your customers and stakeholders.

[adrotate banner=”50″]

About the Author

Daler Sayfiddinov

Daler is an MCSE specialising in Office 365. He builds business applications using SharePoint, PowerApps, Flow and PowerBI. Daler is passionate about automating day to day business processes to save customers time and increase revenue (automateiq.rocks). Connect with Daler on LinkedIn.

Comments

  1. jaideep

    The Real Person!

    Author jaideep acts as a real person and verified as not a bot.
    Passed all tests against spam bots. Anti-Spam by CleanTalk.

    The Real Person!

    Author jaideep acts as a real person and verified as not a bot.
    Passed all tests against spam bots. Anti-Spam by CleanTalk.

    I want to create power bi dasboard by uploading csv data so that i get line chart and bar chart and pie chart in my power bi dashboard and to get the power bi dasboard link so that i can open it in the browser
    the above is the use case i want detailed step by step process to archive the above.

    i want to archive by automatic all the process using python and power bi api

  2. Hussain

    Hello,
    Is there a way where I can use PowerBI to pull o365 data such as Service Status, Threats Reports, security incidents…

    Thanks,

  3. AKSHARA

    Is there any way to select limited columns from source data based on user’s request everytime (mostly dynamically selecting data from back-end based on some user parameter)

  4. surbhi

    Hi,
    As source data , i have to take source file every day (present in a folder created every day named as date for example C:\Users\Output\20200803\file1.xlsx , C:\Users\Output\20200804\file1.xlsx .. so on)
    Then how can i dynamically pick source file in this case.

  5. Joe

    Have you guys done anything for Messaging Tracking or mailbox permissions? It seems like it might be useful

    1. Daler

      It is a possibility. There are couple of ways to achieve the goal:
      – more manual method is when you schedule to run PowerShell to Export cvs and create PBI
      – or use API to pull data from exchange and store it securely and build PBI

  6. Ayesha Zahid Hussain

    Can we switch dynamically between 2 different databases for our reports content?

    1. Daler

      Yes, it just depends how you export data. Need to know your goal.

      Thanks

  7. Luba

    It is difficult to understand about connect to wordpress for beginner.

  8. Suresh

    Thank you for the information! With Power BI Pro how often can i refresh the dataset, can it be real time i.e can we get the data updated for every transaction that happens, as in your example data update is scheduled every week, can we do it every minute or is there any other process. Thank you in advance

    1. Daler

      It will depend on two factors:
      – since data was manually exported via PowerShell from Exchange you have to run your PS script more frequently

      – PowerBI refresh info can be found here
      https://docs.microsoft.com/en-us/power-bi/refresh-data

      If you need more dynamic report, I would use API to achieve the goal

  9. Rafael

    Hola Buena tarde!

    Se puede conectar mailbox a power bi y si se puede como seria esta conexion?

    Saludos

  10. Grant

    This is going to be very valuable for our management. Thanks for sharing.

  11. Jon D

    Great post, as always easy to follow and self explained. Thank you !

  12. Tim

    was looking for a third party solution to do design dashboards. Tried this solution in test environment today, excited to roll it out to production next week. Thank you very much for a detailed explanation.
    Tim

  13. Robert Derbyshire

    Hi – thanks for the post, its really interesting. The P Cunningham CSV generating ps1 you recommend does not work with Exchange Online, can you recommend one please? Thank in advance.

Leave a Reply