Create Reports Using Excel

Accessing the FogBugz database using Excel should be as easy as getting to it from Access.  If the FogBugz database is not already visible as an ODBC connection, Arthur Purves suggests the following steps:

  1. The database administrator has to give you access to SQL Server and to the fogbugz database on the server.
  2. The database administrator has to give you the hostname that SQL Server runs on, and the name of the FogBugz database.
  3. Test that this information works by opening a console and entering (this assumes you are using Windows authentication):

          sqlcmd -S <server's hostname> -d <name of fogbugz database>
          1>SELECT name FROM sysobjects WHERE type="U" ORDER BY name
          2>go
    This returns the names of the 43 FogBugz tables, e.g., Bug, Person, etc.
  4. Now you can set up the ODBC source for Excel.   Open Excel->Data->Import External Data->Import Data->+New SQL Server Connection.odc. This opens the "Data Connection Wizard."  
  5. For "Server name", enter the hostname that SQL Server runs on.  If you're not using Windows authentication here, enter the username and password that the database administrator gave you. Click "Next."
  6. Click the down arrow to select the FogBugz database.  Uncheck "Connect to a specific table." Click Next and Finish.  Now you have a menu for the tables you need.
  7. When you NEXT open Excel, choose Data->Import External Data->New Database Query:  This produces "Choose Data Source."  Select the name you gave the FogBugz ODBC source.
  8. Now you have the "Query Wizard - Choose Columns"  IMPORTANT:  Click the "options" button and unclick everything except "Tables".  Or you can click the down arrow, scroll up, and select "dbo".

Now you can set up a query within the Wizard, or click Cancel and set up the query using MS Access.

Pivot Tables

Pivot tables are super powerful (if you know what you're doing).  They are hard as heck to fully understand (for me anyway), but hopefully this example will demonstrate what they can do.

Excel's documentation says:

"A PivotTable report is an interactive table that you can use to quickly summarize large amounts of data. You can rotate its rows and columns to see different summaries of the source data, filter the data by displaying different pages, or display the details for areas of interest.

Use a PivotTable report when you want to compare related totals, especially when you have a long list of figures to summarize and you want to compare several facts about each figure. Use PivotTable reports when you want Microsoft Excel to do the sorting, subtotaling, and totaling for you."

Recently I needed to figure out how long it was going to take us to fix all of our bugs for the next release (by priority).  Summing up hrsCurrEst for each Project, sorted by Priority was the perfect example for a sample Pivot Table.

I. Inserting the Pivot Table

Choose "Pivot Table" from the "Data" menu in Excel.  When prompted for "Where is the data you want to analyze?", check the button for "External Data Source".  Leave the "Kind of Report" as PivotTable.  Click Next.

Click the "Get Data" button and choose "fogbugz" from the Databases tab.

The "Query Wizard" should now pop up:

Hit "Cancel" on the Query Wizard and it will ask you if you want to "Continue editing this query in Microsoft Query?" Choose YES!

The "Add Tables" dialog will come up and you should add the following tables to the query: Bug, Project, Priority, Person, FixFor, and Area.

Most of the relationships will be defined for you (the lines connecting the tables show the relationships).  You will need to add a relationship between ixPersonAssignedTo in the Bug table and ixPerson in the Person table.  Drag ixPersonAssignedTo from the Bug table onto ixPerson in the Person table.

Delete the line between the Area and Person tables, and the line between the Project and FixFor tables. (Double click on the line, then click Remove)

Choose "File->Return Data to Microsoft Excel".  Hit "Next" and "Finish".

II. Experimenting with the Pivot Table

Now you should see a dialog pop up with all your fields on it (hrsCurrEst, sFullName, sProject, sPriority, sFixFor, and sArea).

First let's get a run down of estimated hours for each priority.

  1. Drop sProject onto the box labeled "Drop Page Fields Here".
  2. Drop sFullName onto the box labeled "Drop Row Fields Here".
  3. Drop sPriority onto the box labeled "Drop Column Fields Here".
  4. Drop hrsCurrEst onto the box labeled "Drop Data Items Here".

You should see a estimate broken down by each person in the database for each priority.  Select a specific project from the drop down at the top of the pivot table next to sProject.

You can drop multiple columns onto the rows or the columns and Excel will break it down even further.  Just remember that we're looking at the current hours estimated to fix the bugs broken down in whatever way you like.  Play around with what you drop on the row and column areas and leave the hrsCurrEst field on the data area and you will get lots of interesting data.