Tuesday, December 4, 2012

The Back End of the Shaggy Dog

I work in tech, and people are forever referring to the "back end" of software, databases, and so on. I find the reference amusing (because inside, I'm 12), but I have to admit that the euphemism fits. The code, meta-data, and other unseen features are not the pretty face that gets shown around. So let's take a look behind the scenes, as it were, of my Shaggy Dog Story with Excel.These instructions are all about MacGuyvering a spreadsheet. While I hope that no one needs them "as is," there are a few tricks here that you might find handy for other projects.


First, I organized my resources on one spreadsheet. Then, I made it into a table. You can do this in Excel by clicking in the cell that will be the uppermost lefthand corner of the table, then using CTRL+T. My table had headers (unit, resource, title description), so I checked that box and hit ENTER. You don't have to turn the data into a table, but (1) I think it makes the formulas easier to manage and (2) you don't have issues with adding records.

Now I have something that looks like this. If you don't like the formatting Excel applies, you can go into the Table options and fuss around with it.



Then, set up your sheet where you want the results displayed. If you're using Excel offline, just use data validation. Don't bother with my "X marks the spot" strategy. However, if you're trying to webify this content, carry on. This is how I set up the demo for the blog post. I used the four column headers (in brown) on this sheet to organize the display.


There are two more small pieces before we get knee-deep with generating a list of items based on user input. First, on the sheet with the list of resources, I set up two IF statements, one for the choices underneath "Unit" and the other for "Category." I needed to tell Excel how to recognize the selections made by the user. Here is how I set up the formula for Unit:

This formula is placed on the other sheet, but since cell references are on this one, I'm showing it here.
Keep in mind that if you're building an offline version using dropdown menus, you can skip this part.

Finally, I set up a COUNTIFS statement based on the user selections. This was also placed on the page with the data set: COUNTIFS(List[Unit],G2,List[Category],G3). This tells Excel to count all of the cells in the table that matched the results of the two IF statements. I named this formula Item_Count. The one I did for work ended up with nearly 30 choices and two extra layers of IF statements...but we won't bother about that now.

An aside here...

I mentioned earlier in the post that converting the data into a table made things simpler for the formulas. Notice that in the COUNTIFS formula that I don't need to state a particular range (e.g. A1:A50). I can just tell Excel to use the table (List) and column header in square brackets (Unit, Resource).

Okay, let's go back to the sheet with the results. We have one more formula to apply...and it's a doozy. Why? We need to generate a list of results based on user input. Our old friends, INDEX and MATCH, are great at identifying the one item that fits a set of criteria...but we need a list. We need Excel to find the first one, the next one, the next one...and so on. Also, the results of each list might not be the same in number--could be one item, could be ten.  I found the basic answer here, if you want to watch a video tutorial; but here's the basic idea for cell B11 shown below. Keep in mind that this is an Array Formula, which means you need to use CTRL+SHFT+ENTER to make it work.

=IF(ROWS($B$11:B11)>Item_Count,"",INDEX(List[Title],SMALL(IF(List[Unit]&List[Resource]=List!$G$2&List!$G$3,ROW(List[Unit])-ROW(List!$A$2)+1),ROWS($B$11:B11))))



If you're hyperventilating after looking at that formula, find a paper bag and come back. We can do this.

The first part of the formula (=IF(ROWS($B$11:B11)>Item_Count,"") means that we want Excel to count the rows from B11 to B11 and compare them to the result of the COUNTIFS formula (named "Item_Count"). If there are more rows than the Item_Count, Excel should leave the cell blank. This part is important because we are going to have a variable number of results based on user input. By including the option for the blank result, we will keep error messages from showing up.

Next, we have the FALSE part of the IF statement---what Excel should do if the Item_Count is smaller than the number of rows. In this case, I want it to INDEX the Resources and display the title based on the following criteria:

  • It must match both the Unit and Category as indicated by the results of the IF statements we set up earlier. (IF(List[Unit]&List[Resource]=List!$G$2&List!$G$3)
  • It must be the "smallest" (first) item that matches the criteria that is equal to the number of rows we've specified +1:  SMALL(IF(List[Unit]&List[Resource]=List!$G$2&List!$G$3,ROW(List[Unit])-ROW(List!$A$2)+1),ROWS($B$11:B11))
The good news is that you only have to build this formula once. And trust me, you will do your Happy Dance when it works. Use your fill tool to copy the formula down. You can also copy and paste the formula to cell E11 for the description, then change "List[Title]" to "List[Description]" in the formula.

You can download the workbook here, or go back to The Shaggy Dog Story and see how things work in the embedded version.

See? That isn't so Ruff! Ruff!

Bonus Round
The gigantic formula shown above has a lot of different uses. Don't discount it just because it looks scary. For example, think of how you might use it to sort a list of students into different classes (i.e. take a master list and sort it onto multiple spreadsheets). Although Excel is not a database tool, this formula gives you some options to use it that way when you need to.

Saturday, December 1, 2012

The Shaggy Dog

Stop me if you've heard this one: Excel, Web Apps, and GoogleDocs walk into a bar...

Okay, maybe that isn't the basis for the story I'm about to tell, but I was nearly driven to drink by these three, um, tools.

As part of my day job, I work with a small database of resources. Until recently, the database has lived on a Moodle site---a long and painful sidebar to this story, which I will spare you. As our story really begins, this database is downloaded into a csv file and begins its new life as a spreadsheet. The goal is to webify this content and make it interactive---all without the expertise (and expense) of a developer. We do have the ability at our workplace to have a table on the web with alphanumeric sorting---but no filtering. This is great for things that you only need to sort on one attribute (and for a small dataset). My pseudo-database didn't fit these criteria.

Part One: The Easy Way Out...Or Not
I tried using the Excel Web App first. I really wanted this to work for two reasons. First, it would be awesome to have the first idea work and be able to end the story at this point. The other reason was simply an IT one: in my workplace, it will be a lot simpler to argue to embed a Microsoft product vs. a third-party app. So, I converted my spreadsheet to a table, uploaded it to SkyDrive, and if you know what you're doing, you can filter the results using the app. But this just wasn't going to work. By the time you built in enough directions to navigate the filters, a novice user would probably just give up on the damned thing. Plus, you could only filter one column, so I was no better off than just the simple sorting we already had.

Part Two: Back to the Drawing Board
I went back to Excel to see if I could get a handle on the some of the mechanics (formulas) I would need to build in the filtering. It's simple enough to build some data validation (dropdown) menus that allow a user to choose. But I had to learn how to generate a dynamic list from these choices. It's one thing to use INDEX and MATCH to find one item on a spreadsheet...but how do you use it to find all of the items for a set of criteria? A list that will change with every possible combination of input from the user? Yikes. I did find the answer to this and built a little interactive form. It worked great offline, but I couldn't move it onto the web, because the Excel web app doesn't support data validation. But hey, Google does!

Part Three: A Move to the Dark Side
Let's give Google Spreadsheets a crack at things, eh? I uploaded the workbook..even figured out how to make the array formulas work. The dropdown menus were functional. But then, Defeat was snatched from the jaws of Victory. You see, the dropdown feature only works in the spreadsheet---it doesn't work if you embed it in another webpage. Argh. So, I decided to build a Google Form for the input and connect that with the spreadsheet to generate the dynamic lists of resources. Um, no. Again, it worked great in the live worksheet, but didn't make a bit of difference for the embedded one. Le sigh.

Part Four: Gee, It's Good to Be Back Home Again
I'm starting to get pissed. Twice now, I've gotten down to the very last piece of the puzzle, only to find that it doesn't exist. But I'm also a bit more focused on what needs to happen. Whatever gets developed needs to (a) live on SkyDrive, (b) be intuitive for the user (c) not need data validation or VBA. So, I'm back to square one with Excel, begging my old lover to take me back and teach me some new tricks. I ended up building some IF statements based on whether the user placed an "X" beside a choice and used that for the input. The only final piece was to use the HYPERLINK formula to piece together the title and location of a resource from the spreadsheet with the data into the list for the user, so they could just click-n-go.

Part Five: It's Alive!
After some final formatting, I uploaded my Frankenspreadsheet to SkyDrive, and it worked. I suppressed my urge to run around the office like Colin Clive in Frankenstein and scream "It's Alive! It's Ah-liiii-ive!" I admit that it's a little clunky, but it meets the criteria it has to satisfy.

I've mocked up a sample using different a different dataset for you to see (without hyperlinks, since these refer to documents instead of webpages). If you're viewing this post via RSS, you'll have to click through to the original post to see the embedded spreadsheet.I'll give you the background on building this in the next post. For now, any suggestions for improvement?


To play with the spreadsheet, place an "X" beside one item in the list of Units and an "X" beside one item underneath Category.

Tuesday, November 27, 2012

Come on Over

Did you know there's a Facebook page for this blog? It has an RSS feed, as well as miscellaneous news from the data viz world. Here are a few items recently posted:
 Hope you'll join the conversation on Facebook!

Sunday, November 25, 2012

Ah! Something New Has Been Added

During my hiatus over the summer, a few readers were working hard with Excel and were kind enough to send along questions and comments. So, as I catch up on hosting duties here, let's pull out an item from the mailbag and see if we can share some solutions.

Mark2906 asked, "If I need to add more assignments to a particular standard (say 11 tests instead of 7 or 8), how do I alter the formulae for calculating predicted scores?"

from here; Do you know who this is?
Excellent question. No one wants to be stuck manually updating their spreadsheet every time an assignment is added. It's nearly 2013, dammit, and if we can't have flying cars, we can at least have our spreadsheets make an effort to help out around the place.

The good news is that Excel will tag along for most of the adjustments you make to your spreadsheets. Need to copy, move, and paste some data? It will update the formulas automagically.

But that's not quite what Mark has asked us. In many K - 12 classrooms, you don't know exactly how many assignments/pieces of evidence you will be collecting for a particular standard or unit of study. So, here is the simplest way to address this.




Leave Room to Groove
There's no rule that all of the scores in your gradebook have to butt up against one another. When you create a new section for scores, just label more columns than you think you might need. For example:

We're Off on the Road to Excel...
Two sections for standards are shown, each with space for ten assignments. So far, we've recorded five scores for the first standard, and three scores for the second.

To determine the average for Jerry Colonna on the first standard, we can use the following formula: =SUM(C4:L4)/COUNT(C4:L4). We can then just copy the formula down for the other students. Excel will not treat the empty spaces as zeros. Should you need more columns, just insert them after the last assignment and the formula for the average will keep up with you.

If blank columns are occupying too much real estate, you can always hide them.
Peek-a-boo!

Other Ideas to Consider
There are such animals as Dynamic Named Ranges, which expand to fit the data supplied. You can read more about them here or see them in action here. Although they can be very handy, I think they're overkill for this particular problem.

I'm sure there are other solutions, including VBA options. Please share your additional ideas in the comments.

Wednesday, November 21, 2012

Building a Better Heat Map

In the last post, I shared my version of a heat map created in Excel. Now it's time to get into the details of the build.

After you've organized your data in Excel, start a new sheet for the heat map. When I did a "back of the napkin" sketch for this visualization, I knew I would need 37 columns: one for the name of the district, and 36 others to fit three years of data points for four areas (dance, music, theatre, visual) for three grade bands. I labeled my rows and columns.



Next, I created a formula to fill in the data points. Because the values for each cell were a proportion of the grade band, they were all a variation of this one for cell C5, the first one for the District A: =2010!C2/SUM(2010!C2:F2), where 2010! represents the sheet with the data for the year 2010, C2 the cell with the drama number (if any) for elementary, and C2:F2 representing the four cells of elementary data. That's it. Use the fill tool for the rest of the cells.

If you're wondering why I have each year on a separate sheet---there's no good reason, other than it was handed to me that way. I could have easily pasted all the data into one spreadsheet. Do as the Excel spirit moves you.

Let's talk about color for a moment, before we dive into conditional formatting. If you need a two-value system (e.g. to represent gains/losses), remember to stay away from green/red. It's not friendly for those with colour vision issues. Orange and blue is better. For a single value system, blue works well. Why on earth did I pick purple, then? Aesthetic reasons. Blue worked fine, but seemed a bit boring. The purple just seems to suit this data set. If you need help with colour scales, you might start with the Color Brewer.

Also, why do I have ten categories? It seemed like a natural fit for a scale based on percentages---I stuck with the base 10 scheme. My full data set for this piece has over 9000 data points and I wanted to see some nuance. But I could just have easily picked quartiles or another factor. Which one should you choose? Ah, that's part of the art of data science. You really need to play with your visualization a bit to find out what cut values work best.

Okay, let's dive in to the conditional formatting. You're going to need 11 rules. Why 11? Because we also want to create one for any 0 or blank value.


For each rule, tell Excel to do with a range of values---your instructions should include the color for that part of the scale as both the font and fill. This way, you will "hide" the number in the box. Go ahead and put a bunch of 9s at the end of the upper limit. If you have a big data set (and who doesn't like 'em big?), you're going to want to account for all the little variations within it.


Your last formatting job has to do with the borders. In the menu for borders, make each cell have a thick white outline. This will make your coloured boxes look separated. Go into the View tab and uncheck the box next to "gridlines."

The invisible border dialogue
Okay, now you need to change the width of the columns and rows to create squares. Just do the old select and slide until everything looks square.

Finally, use the shape tools to add some very thin grey lines between each chunk of the data set. Yes, you're actually going to draw in those borders.


I made mine a little longer between the grade levels than between the different arts areas.

Guess what? You're done.

One of the things I like about this project is that it's simple, but rich and interesting. The more time you spend, the more you notice the little nuances...things you might never see from just the numbers alone. I think this project also illustrates how much of design is not about the number-crunching. There's just one formula here. The rest is making Excel turn that data into something visual. And yes, that takes some time and finesse (it is Excel, after all...not a tool that was developed for data design), but you can do it.

So get out there and make something that grabs people's attention because it's pretty. And when you've done that, come back and share it here.

Saturday, November 17, 2012

A New Spin on Heat Maps in Excel


There are lots of heat maps out there. We saw many different versions during the election cycle---everything from campaign financing to election results. These visualizations use a scale of color values to communicate a range of data. Some vary the intensity of a single color value to represent a variable (e.g., the greater the population in an area, the darker the color). Others use two values to present a comparison (e.g., increases and decreases to population over a given time period).

Excel does not have a heat map option in its charts; however, you can use conditional formatting and some other design options to create a really fine looking visualization.

One of the graphics included with Stephen Few's workshop presentation was this one:

Market Segment from Stephen Few's Now You See It

I was really taken with it. It's a simple layout, but packs a punch in terms of showing the data. It was the perfect fit for a data set I was wrangling. Take a look at my version (there is an interactive version at the end of this post):


What you're looking at is some data about the different areas of the arts (dance, music, theatre, and visual arts) for three grade bands (elementary, middle, and high school) over three years (2010, 2011, 2012) for districts in Washington state. Please note that although this data is public, it is only available to those who ask. Therefore, I have made some modifications to what I am sharing here: no districts are identified by name and I am only including ~50 districts.

Never underestimate the power of pencil and paper when planning a visualization. Using the version from the workshop as a model, I sketched the layout for this, as well as how to fill the cells. I decided not to use number of students as a factor, as that would skew things based on the size of the district. Instead, I wanted to look at each arts area as a portion of overall enrollment in the arts. In other words, what percent of elementary students in a district had access to instruction in dance vs. music vs. theatre vs. visual arts?

There is a single color scale. The greater (darker) the intensity, the greater the percentage for that area of a grade band. Blank spaces represent a lack of data. This might be due to no instruction offered in that area, but it could also mean that we just don't have any data from the district. Don't read too much into those.

Even though I used a single color (purple) for this visualization, it is still simple to look at gains and losses over time. For example, for District A, we can see that at the middle school, music instruction has decreased over the last three years...and the percentage of students involved with the visual arts has increased.


Similarly, I can see some big trends when viewing the entire data set at once.

Notice how popular Music is at elementary? There are a lot of dark squares in that second column. While not as strong, there is a definite preference at the high school level for visual arts, based on what I see in the last column.

The benefit of a heat map like this one is that it allows you to visualize a lot of data at once (there are over 1500 data points in the image above, including blank spaces) while not losing any of the points.

In the next post, I'll get into the nitty gritty about how I built this. For something that looks rather elegant (if I do say so myself), there is only one formula involved, with some conditional formatting and shapes applied. In the meantime, if you want to play with the spreadsheet a bit, use the Excel Web App below. Sorry about the horizontal scrolling required, but you can also click the bottom right-hand corner to view the sheet full screen.


Thursday, November 15, 2012

Dashboard Design for Education

I've posted several versions of reporting tools over the young life of this blog...but I haven't shared any dashboards. I've been holding onto my ideas for other purposes, but that doesn't mean I haven't spent time perusing what others are doing.

I have yet to find a commercial product that I would recommend. Every implementation of Cognos I've seen so far has been awful enough to make me beg for eyebleach.

3D Stacked Cylinders. Yes, really.

I spoke with an Edmin rep for awhile this summer. Very enthusiastic about their product, but admitted that they'd never consulted with any designers about the interface. It shows. Engrade suffers from the same issues. Here in Washington state, something called Homeroom has rolled out to most districts. When I talked to these reps nearly a year ago, they bragged about how their design was based on what teachers wanted. In fact, all these companies say that---and that's great. Knowing what data your audience needs to see is critical. But most educators are not designers and the incredibly poor output for all of these companies reflects this. I am disheartened by all the rich meaning that is hidden or lost because none of these companies can be bothered to consult with someone about line, color, and other basics.

But what happens when we build a design and don't have audience input? You get a very pretty dashboard...but is it useful?

Stephen Few recently hosted his annual dashboard design competition. (For a full discussion of the entries and selection process, visit his blog.) And this year, the challenge was to develop a student performance dashboard. Here is the winning design, by Jason Lockwood:

from http://www.perceptualedge.com/blog/?p=1374








It's very pretty---and very Few'ish: the colors, the style, the fonts, and so on. Once you know what Stephen likes, all of the dashboards look the same. (I'm not sure that's a good thing, but we'll save that discussion for a different post.) The second place design, by Shamik Sharma, is below:

from http://www.perceptualedge.com/blog/?p=1374

I think the challenge with educational data is simply that it's hard to "snapshot." We need to see every student---not just the Top 5. And there is a lot of stuff to consider---not all of it fits neatly into little quantitative variables. As I mentioned to Mr. Few at the workshop I attended, schools aren't making widgets: we're about people.

Those who entered this contest used a dataset that was provided to them, so I can't blame them for the volume of information contained here. But as I look at these as a teacher, I see information that isn't necessary for a dashboard (e.g., the standardized assessment results) and a lot of very poor grading practices represented (e.g., averages and letter grades). The designs are completely disconnected from the real-world audience. It is a limited audience, at that. These dashboards might be adapted for use in a secondary (or higher ed) core subject classroom, but not for elementary (multiple subjects) or performance-based classes (like PE). In short, the designs have a beautiful form and almost no function.

Can't we all just get along? How do we get those with expertise in the classroom connected with those who have expertise in data design? What would you like to see included with a dashboard?