(Click Watch in the top right corner if you want to get an email when this tutorial is updated)
This tutorial will walk you through how to use Microsoft Excel to build a simple dashboard using CommCareHQ data exports. CommCare is an open source platform that enables people without a tech background to design and deploy their own mobile applications. By the end of the tutorial you will be able to create a dashboard that:
- Requires upfront work by an administrator just once, and then is easy to maintain going forward
- Refreshes automatically from CommCareHQ when you reopen the report (or set time based refresh).
- Allows users to filter the dashboard for information relevant to them without detailed knowledge of how Excel tables work.
- Enables an administrator to quickly make new reports and send to end users.
The intended audience for this page is a CommCare administrator who is familiar with CommCareHQ and has some experience in Excel. The end result will contain the following:
**** Download the Example Dashboard ****
A graphical dashboard
Individual pages with data:
User definable filters:
Excel Version: This tutorial was written for Microsoft Excel 2010. Most of the functionality described is also available in earlier versions of Excel though may be called different names.
CommCare Dashboard.xlsx: The Dashboard file. Open this to see the final product.
Raw Data.csv: The raw data downloaded from CommCare for reference.
Step 1: Create Custom Export in HQ for the project
- See this Data Export Overview page for details on creating the data export:
- Name your export
- For Default File Type choose Web Page (Excel Dashboards) as the Default File Type.
- Choose Automatically convert dates for Excel
- Choose Create a Daily Saved Export
- Be sure to rename your Display columns to how you want them to display in your reports.
- Save the export
Step 2: Copy the Web Address of your saved export
When you chose to Create a Daily Saved Report in step 1, this meant every night CommCare will generate the export with all the latest data and save it. We will use this report to pull into Excel.
- Scroll to the bottom of the Data Exports Page
- In the Daily Saved Exports section you will see your saved export.
- Click Update Data button to generate the first report.
- Right-click on the Dowload link to the export
- Choose Copy Link Address in the menu. This will copy the URL of the export file so you can paste into Excel in the next step.
Step 3: Create the Excel Connection to your export
The next step is to create the file that will hold the reports.
- In Excel, Create a New File.
- You will have a blank Excel file now.
- Go to a blank tab in your workbook. Rename that sheet "Raw Data".
- Select the top-left cell (A1).
- Now we will pull in the data from the Excel file
- Choose the Data menu
- Choose From Web in the "Get External Data" section
- Be sure you have Copy link address from step 2 above so it is on your clipboard.
- The "New Web Query" window appears.
- In the "Address" bar at the top, Paste the link you address you copied in Step 2 above. It should be something like "https://www.commcarehq.org/a/excelreportingdemo/reports/export/saved/download/96c41fd6fb9be6119ad32467254cbc9a/"
- Click Go
- The "Windows Security" window appears. Type your CommCareHQ username and password.
- The export will be displayed to you in the Web Query Window
- Click the second Yellow Arrow above the table of data (not the very top one). This will select all the CommCare data in the export.
- Click Import
- The "Import Data" window appears.
- Click Properties
- The "External Data Range" window appears
- In the top of the window, name your export "Raw Data"
- Choose Save query definition
- Untick Enable background refresh
- Choose Preserve Cell Formatting
- Choose Adjust column width
- Choose Overwrite existing cells with new data, clear unused cells
- Choose Fill down formulas in columns adjacent to data
- Click OK
- Click OK again
- The data is pasted into the empty worksheet
Step 4: Name your raw data for easy reference later
- Now that your data is in the Raw Data tab, we want to name it so we can refer to the data later
- Select all the columns that have data in them by clicking on the top of the columns while holding shift.
- With the columns selected, click in the text box above column A (It likely says "A1" in it)
- This is where you type the name of the raw data for reference later. Name it "raw_data".
- Now, whenever you want to reference the raw data you can type "raw_data" in the formula instead of "='Raw Data'!A:E" like you normally would.
Step 5: Create the first Pivot Chart
The first chart we will create is the Line Graph of Expected Delivery Date. This will plot the number of women expected to give birth in each month, broken down by Clinic.
- Create a new tab called "Expected Delivery Date"
- Select the top-left cell (A1) in this tab
- In the Insert menu choose Pivot Chart from the PivotTable icon
- In the window that pops up, click "Table/Range" text box
- Type "raw_data" into the box. This references the data range we created in the step above and is a lot easier than selecting all the columns each time.
- Click Ok.
- This creates a blank pivot table.
- Click the pivot table on the left
- In the Field list on the right, do the following:
- Drag Expected Delivery Date to "Row Labels"
- Drag District to "Column Labels"
- Drag District to "Values"
- Note: If you don't see the "Pivot Table Field List" on the right, click the Options menu at the top and choose Field List in the top right.
- This will be the result:
- We now have the data we want but it needs to be formatted:
- You can drag the graphical chart to the side to get it out of the way
- Next, we need to display the dates as months instead of days
- Right-click on any of the dates in the pivot table and choose Group
- Select Months in the list the appears and choose OK
- This groups all the EDDs into monthly buckets
- The graph defaults to a bar chart, but you can change it:
- Right-click the graph and choose Change Chart Type
- Select the line graph you'd like
- Set the table to update automatically
- Highlight the pivot table
- Choose the Options menu and in the top-left type the name "EDD Graph"
- Click Options below where you just typed
- On the Data Tab select Refresh data when opening the file
- Finally, rearrange the layout by inserting rows above table to move it down and drag the chart to the top of the page.
- You can add titles and legends with the Layout menu
- You're final result should look like this:
Step 6: Create Additional Pivot Charts
- Repeat all the steps in Step 5 as many times as you'd like to create more charts
- In this example, see the screen shot for how the "Patients Received Vaccines" chart was made.
- Be sure to set all table to update automatically (Step 15 in the section above)
Step 7: Create Filters
- Excel uses "Slicers" to enable users to filter the reports in a user-friendly way.
- For the first pivot table you created do the following:
- Select the chart you created
- Choose Analyze menu at the top
- You may need to select Options menu instead
- Choose Insert Slicer from the menus
- Select the items you will want to filter your reports by and click OK.
- Drag the filters and resize them to fit the layout as you like
- Now we want this filter to apply to all charts in our Worksheet, so we connect the filters to the other tables by:
- Select one of the filters you just created
- Choose Options then PivotTable Connections
- Check all the boxes for the other tables you created.
- Now changing this filter will change the filters on all the tables you created.
- Repeat this step for all filters
- Copy and Paste the filters to other areas of your Excel sheet if you'd like them to appear in more than one place
Step 8: Build the Dashboard with Copy-Paste
If you'd like to display all the charts on one page, you can copy and paste the reports and table anywhere you'd like
- Create a new tab called Dashboard
- Copy and Paste the charts from other tabs in to the dashboard tab
- Copy and Paste the filters you created, if you'd like
- A sample dashboard looks like:
Step 9: Hide the Raw Data
One of the challenges with Excel reporting is ensuring that users you send the reports to do not accidentally corrupt the data or people get confused with too many options. We can mitigate many of these issues with two methods:
- "Protect" all data
- Right-click each tab and choose Protect Sheet
- Scroll to the bottom of the list and check the box for Edit Objects and Use PivotTable Reports
- This will allow users to change filters but not edit the data
- Do NOT protect the "Raw Data" tab or the data will not update automatically
- Hide the Raw Data tab (if desired)
- If you'd like to hide the raw data tab, you can right-click it and choose Hide
- To unhide, right click on any sheet name, choose Unhide. It would show you the list of hidden sheets and you can pick the one to unhide.
- Choose PivotTable option in Step 4
- Instead of putting the raw data on a tab you can directly make pivot tables when importing.
- This means the raw data tab will not exist but the pivot tables will.
Step 10: Refresh Your Data
Each night CommCare will save the updated data to that file. To have Excel pull in the latest, do the following:
- Choose Data menu
- Click Refresh All
- This will pull the latest data from CommCareHQ. You will be prompted for your password.
If Excel hangs during the refresh, disable Enable Background Refresh on all data connections. This is a known problem for spreadsheets with multiple web-based data connections. Find it under Data -> Connections -> Select Connection, click Properties -> unselect Enable Background Refresh.
Step 11: Send to Others
If you just send the Excel file to others they will be prompted to enter login credentials in order to refresh the data. If you don't want this to happen, you can do the following:
Option 1: Delete the Connection to the Raw Data file
- In the Data menu choose Connections
- Select the Connection you made and choose Remove
- This file will no longer update automatically but will still retain the most recent data.
Option 2: Export to pdf (might not be available on all computers)
- Chosse File - Save As
- Select PDF as the File Type