Everyone! We've moved to WordPress.

Directly link Excel form controls to backend data with dynamic references

0
Form controls are great for reporting information about groups of items, like a list of programs or accounts. They are often used on Excel dashboards and reports that demand interactive capabilities. One such type of capability provides the user with a list of items to choose from. When the user makes a selection, a macro is executed that populates a table holding referenced values. Those values are linked to a series of form controls on the frontend. This interactivity is displayed below:

Step 1


Step 2

Step 3

There is a final step, which I haven't included. The user would make changes to the project under the Options table. They would press a "Save" button and their changes would be copied from the Linked Values table back onto the backend data in the column corresponding to the selected project using VBA.

The No-VBA way

There's nothing wrong with this method in and of itself, but I want to propose a method that requires no VBA. The advantage of this new method is that it links directly to the data itself and bypasses the need for the Linked Values table. We can do this by allowing the form controls to take advantage of dynamic references.

Typically, form controls can only do direct, absolute references. You cannot, for example, use VLOOKUP or INDEX within the source field of a form control. However, you can use a named ranges.

Let's do it!

First, we give that 'index' field above a named. How about selection? Next, we create four named ranges to correspond to the form control checkboxes. Stage_1 to Stage_4 are those new named ranges.

As you can see from the picture, I use the fourth row to connect to checkbox Stage 4 and the selection value to inform Excel to pull from the fourth column in the backend data (which is Project 4, if you recall).

Finally, I can simply link these named ranges to their associated checkboxes:


Using this method, changes to the checkbox automatically change the backend data. There is no intermediate table required -- like the Linked Values table above -- to interface between the frontend and the backend.


That's all for now - have a happy and health holiday season!

Update 25 December:
Make sure to see the download file - Direct Links.xlsm.

Easy One-Way Sensitivity Analysis on Weighted Sum Models in Excel (Part 2)

0
Wow, it's been a while since my last article. I've actually been pretty busy the last few weeks putting the finishing touches on an Excel deliverable for one of my company's clients. We delivered the product about a week ago and things have just now started to slow. So now it's back to blogging.

If you've been following so far, we left off with Easy One-Way Sensitivity Analysis on Weighted Sum Models in Excel (Part 1). In that article, I describe a method for automating one-way sensitivity analysis, and, in Part 1, we construct the mechanism that drives the automation. However, where we left off, our sheet was a bit ugly. Sure, the mechanism worked, but it wasn’t a dashboard. We’ll talk about making a dashboard in this article, Easy One-Way Sensitivity Analysis on Weighted Sum Models in Excel (Part 2). If you’re scratching your head at this point (“what the heck is sensitivity analysis?”), go ahead and start with Part 1. There, I give a brief introduction to the mathematics and rational behind sensitivity analysis (and the weighted-sum model) before going into the Excel stuff. Also, these tutorials are a bit on the long side, so you may just want to do the analog thing and print them out instead of following along on here. 

I’ve been scratching my head as to how to segue from my last article to this one. I’ve decided to do what good chefs do and start with something already prepared. So go ahead and download this file: Healthcare Sensitivity Analysis Example.xlsx. You’re welcome, of course, to recreate the layout of that file, but I’ve done the heavy lifting for you. The core difference between this file and the one you created in the last blog post is that I’ve added many more countries (with fake data). Let’s get the lay of the land of this new file.

If you start with the Data tab you’ll something similar to our last blog post.


The table on the left isn’t all that different from the last file. If you play with the scrollbars, you’ll see that they work exactly as they did before. In the table to the right, each metric has more information broken out than in our last spreadsheet, but the mechanism we created before is exactly the same here (notwithstanding the extra information). Note, too, that the final weighted scores have been moved the front (that is, to the first column on the left) of the final table. You’ll see why at the end of this tutorial.

(The reason more info is broken out is because that info is used in the Healthcare Analysis dashboard in the Fun Downloads section. We won’t use those extra columns here, but if you get the hang of this stuff, consider creating a dropdown to individual weighted scores using that extra information. I might write about how to do that in a Part 3.)

Now click the Example tab. You should see the barebones of our dashboard. If you scroll all the way down (or zoom out) you should see another table below the dashboard called VLookup Table.

Dashboard 

Intermediate Table

This table is an important, if unnecessary, intermediate step. I say unnecessary because you could go without out, but I wouldn’t recommend it; the table makes life much easier. So, this is my advice: whenever you make a dashboard, you should have an intermediate table off-screen that summarizes most of the selection and number crunching for you. For the computer science and java geeks out there, think of this table as part of the model-view-controller framework. The dashboard is our view, or “reporting” layer – it reports data to the users, but it doesn’t allow them to make specific underlying changes to it (they can only change how the data is shown to them). This intermediate table acts kind of like a controller. It handles input stuff like scrolling, and it’s usually only for the Excel developer and not for the client or front-end user (that’s why it’s off-screen). Finally, the underlying data on the backend is our model. I admit that’s a pretty rough explanation, but it serves this very fundamental point to dashboard creation: you should separate the reporting, event handling, and underlying data areas on your spreadsheet. This separation mitigates damage caused by underlying and user-created errors and separates the logic of your work into distinct modules. In other words: it makes life easier.

Let’s go.

Step 1: Link the percentages from your data to your dashboard. 


Start by selecting cell I3 on the Example tab and link it to cell E4 on the Data tab, which holds its corresponding weight. Then go across the boxes on your Example tab and ensure that each cell is linked to its correct proportion on the data tab. Your numbers might be different from mine above, but if you do everything correctly, your mapping should look like this:
Health Level                → Data!E4
Responsiveness              → Data!E5
Financial Fairness          → Data!E6
Health Distribution         → Data!E7
Response Distribution       → Data!E8
It’s always good to double-check to make sure your references are correct. Check twice, reference once.

Step 2: Copy the scrollbars to your dashboard. Resize accordingly.

Remember those scrollbars from the last blog post? They’ll come in handy here. Go to the Data tab. While holding down Ctrl, select all five scroll bars by clicking each one individually. Press Ctrl+C to copy them. Next, go to your dashboard on the Example tab. Press Ctrl+V to paste to your dashboard.

You’ll now need to adjust the size of each scroll bar – then position it next to each number as shown below.
 

Pro Tip: You can make your life easier by selecting the first scrollbar on the left (select it with a Ctrl+Left-Click) on your dashboard. Move the control on top of, or near, the Health Level box and adjust it to the desired height. Use the arrow keys on your keyboard to fine tune its placement (you may need to adjust the height one more time). When you like the scrollbar’s size and position, right-click and select Format Control. Select the Size tab. Take note of its current Height and Width (write it down if you need). Click OK.

Now select all of the remaining scrollbars using the Ctrl+Left-Click as you did in Step 1. Right-click any one of the selected scrollbars, then select Format Control. In the Height and Width boxes enter the information you just noted. Click OK. Each scroll bar is now the right size. Move each scrollbar next to its associated number. Use the arrow keys to fine tune if you’re neurotic (like me!).



Lookin’ good….

Step 3: Create the scrolling indices to show each country.

On the Example tab, scroll all the way down to the VLookup table. In cell F32 of the Example tab you should see only the value “1” alone, by itself. In the cell below the 1 (F33), type =F32 + 1.

Hit Enter. Now drag cell F33 down until you reach the value of 15. Next, go to the Developer tab and insert another From Control scroll bar to the left of the column of numbers we just created. Just like in Step 1, we’ll link this scroll bar to a specific cell on the sheet; in this case, we’ll link it to the cell that held the 1, cell F32. So right-click the scroll bar, then select Format Control. Click the Control tab. In the cell-link box, select (or type) F32. Click OK.

Press the up and down arrows on the scroll bar to see the indices change.

Step 4: Use the indices to pull the final weight values from the Data tab.

Here, we’ll use the scrolling indices to pull information from the Data tab. We can use the Large() formula to ensure the data we pull is sorted. Use the scrollbar to scroll up so that there is only a 1 in F32. (If you see a zero in F32, you’ve scrolled too far. Scroll up one.) Now, in the cell to the right of it, type "=Large(". Now select the entire column of Final Weights from your data tab, Data!G4:G53.


Hit F4 to make it an absolute reference. Type a comma to go to the next parameter. Now, go back on your Example tab, select the 1 (cell F32) to the left. Your formula for F3 should look like this:
=LARGE(Data!$G$4:$G$53,Example!F32)
What we’ve told Excel to do is pull the greatest value from the set of Final Weights. Hit Enter.

If we drag that formula all the way down, we are then telling Excel to pull the second largest value, third largest value, and so forth. Thus, the resulting values in the Largest Values column are always nth largest value, where n is the number in the cell to the left. That’s how we make an automated sorted list. 

Step 5: Fix the Scrollbar minimum and maximum values.

If you play with the scroll bar, you’ll see that scrolling all the way up or scrolling up the way down results in #NUM errors. This happens because we only have 50 countries to choose from. Indices less than one or greater than fifty are outside the bounds of our set. So right-click the scrollbar, select Format Control. Select the Control tab.

Right away, we know that the Minimum value should be 1. But if we have 50 countries in our set, what do you think the maximum value should be? Hint: it’s not 50. Remember, we’re only changing the value in cell F32, the rest of the values are calculated for us on the spreadsheet. So the maximum value should actually be 36. Why? Because while we have 15 different indices showing, one of them is the cell link and the other 14 are calculated on the spreadsheet. 50 – 14 = 36.

In Sum: 
Minimum Value: 1
Maximum Value: 36 
Click OK.

If you play with the scrollbar, you’ll see that it keeps the indices within the correct bounds.

Step 6: Use VLookup to take largest values to its corresponding information.

In the first cell to the right of the Largest Values column (cell H32), we’ll use the Weight Value to the left as a lookup value. Now, do you see why I moved the final weighted scores all the way to the left on the ata tab? It’s a lookup column now! So, in Cell H32, you’ll have something like the formula shown below. But rather than typing what I have, try to recreate the formula yourself. Then double-check to ensure that our work agrees. 
=VLOOKUP(G32,Data!$G$4:$R$53,2,FALSE)
(1) G32 is the weighted score;
(2) Data!$G$4:$R$53 is the entire table from the Data tab;
(3) 2 tells us to pull from the second column, that’s the name of the country we’re interested in; and,
(4) FALSE ensures an exact match.
But wait, the VLookup Table on the example tab has a column for each metric, and we've only filled in info for one column. We’re not just interested in the second column from the table on the data tab. We’re actually interested in columns 2, 4, 6, 8, 10, and 12 as demarcated in red below.



We can actually pull all that info out with only one VLookup. On your data tab, select H32. Now, rewrite the VLookup formula as follows:

=VLOOKUP(G32,Data!$G$4:$R$53,{2,4,6,8,10,12},FALSE) 

Note we have changed the formula from looking up only column 2 to looking up a set of columns. Ensure that you use the curly braces to surround your set of columns as shown above. Now drag the selected cell to the right until you reach column M, the end of the Vlookup table. With H32:M32 still selected, click into the formula bar, then press Ctrl+Shift+Enter. Viola! We use the Ctrl+Shift+Enter here because the VLookup is returning an array of numbers and not just one number. Now drag the selected row all the way down to fill the table. If you’ve done everything correct so far, your table should look like mine.


Use the scrollbar to see the values change.

Step 7: Map the values from the intermediate table to the dashboard.

First, select the scrollbar to the left of your VLookup Table. Press Ctrl+C to copy. Scroll all the way up to the dashboard. Now paste. Move this new scrollbar to a location on your screen that makes sense. You could put it between columns E and G. Or, you can put on the right, as I have, to the right of column O.


Looking at your dashboard, select cell G6. Set G6 to reference the nation at the top of the list in the VLookup table. So, G6 should have “=H32” as its formula. Now drag G6 down 14 rows. If you see one of your rows start showing a value of “0,” you’ve dragged too far. Now, while looking at your dashboard, select cell O6. Map this cell reference the first weighted score on your VLookup table. O6, then, should have the value “=G32.” Drag down. The preset bar charts should show up automatically.

Now play with every scrollbar on the dashboard.

***

This is a good stopping point for Part 2. I might be working on a Part 3 as time allows. If I end up writing a Part 3, we’ll talk about how to make those bar charts. And, we’ll talk about how to build another graph that shows how each country performed in just one metric. Lastly, we’ll talk about how to populate the top and bottom rankings.

If you're really curious about the incell bar charts, you can see a good discussion on Chandoo's site,
How to Visualize Survey Results using Incell Panel Charts.

Questions? Feel free to ask.

Easy One-Way Sensitivity Analysis on Weighted Sum Models in Excel (Part 1)

3
This article describes what I like to call "Easy One Way Sensitivity Analysis" in Excel.  I've used it before in several dashboards.  If you want to try it out for yourself before reading ahead, both Healthcare dashboards on the Fun Downloads page implement my Easy One Way Sensitivity Analysis method.  Here's a pic of one of those dashboards:


Above, you can use the scroll bars to change the weights for each given metric.  As you change one weight, the others change proportionally, just as you would expect with one-way sensitivity analysis. In Part 1, I discuss how to build the structure that drives this functionality.  In Part 2, I'll discuss how to put it on your dashboard.

Below I begin with a review of sensitivity analysis and weighted-sum models.  If you'd like, you can skip the review and go right to the instructions, here.

Review
The title of this article may seem like a mouthful, but don’t let the technical words fool you.  It’s likely you’ve seen this stuff before.

Imagine, for a moment, you are evaluating the healthcare systems of different nations.  After considerable research and many hours with healthcare experts, you decide there are five key criteria you will use to evaluate each nation’s system.  They are:

Health level - a measure on the overall health of a country
Health distribution - a measure of how equally healthcare resources (above) are distributed across the country
Responsiveness - a measure of the speed of health services, doctor’s choice, amenities, etc.
Responsiveness distribution - a measure of how equally healthcare responsiveness (above) is allocated across the country
Financial fairness - a measure of how citizens in each country “fairly” distribute the financial burden of the healthcare system

Not every metric is equal, however.  And, after some careful thought, you decide that each criterion should be weighted by a proportion of its importance to the overall performance of each system.  The weights are as follows:


This model may not look familiar, but, in fact, it’s the very same criteria and weights used in the landmark World Health Organization study, World Health Report 2000: Health Systems, Improving Performance, which assigned a rank to 191 different countries based on the performance of their healthcare systems.   Indeed, this model is used in many published rankings. It works like this: you define the key metrics about the subject you want to investigate and assign each a weight.  You then collect data about each metric resulting in an overall score for that metric. For example, you could collect surveys from healthcare professionals ranking their healthcare networks on a scale from 1 to 10 and then average the results (I'm simplifying a bit). Finally, you would multiply each metric by its associated weight then sum those products together to come up with an overall score. If you understand me so far, then you get the weighted-sum model.

In the published rankings above, the weighted sum model is used to evaluate many different countries. Broadly, you’re simply investigating a resultant list of alternatives whose scores follow directly from the importance of each input defined in the first step. As such, you may want to investigate how changing the importance of inputs impacts the overall score. This is called sensitivity analysis.

One-Way Sensitivity Analysis

One simple, if powerful, sensitivity analysis method is to vary only one weight at a time while maintaining the proportional importance of the other weights. This is called one-way sensitivity analysis and it works like this:

Say I want to test what happens if I increase Health Level by 4%.  First, lets divide the weights into two theoretical groups,


The rule here is that each group must always sum to 100%. So, if we add 4% to Health Level, we have to subtract it from the other group.


Now that the overall sum of the "other group" has changed, the weights that make up that group are adjusted while maintaining the same proportion to the group's sum as they did before.  First we find the proportion...
Then multiply by the new group weight...


Finally,
...our weights again add up to 100.0%

Easy One-Way Sensitivity Analysis in Excel
The above method may appear daunting, but we can make Excel do most of the work for us. I call my "easy" because it's both straight-forward and requires no VBA to implement.  However, it has some limitations that will become clear by the end.


Step 1 - Set up your calculations table

This is how I set up my calculations tab tab:


Note that I have my weights listed on the left side.  I'm given some space between my weights and my score table.  Note, too, that I have all the multiplication set up.  You'll likely want a similar layout. Of course, to save some time, you can download the workbook above with the layout already set up (use the Example tab).

Step 2 - Insert Form Control Scroll Bars, One for Each Weight 

Go to the Developer tab.  Select Insert > Form Control Scroll bar.  (If you don't see the Developer tab on your Excel screen, you'll need to enable it.)


Insert five different scroll bars below the weights table.  Or, better yet, insert one, then copy and paste.

Step 3 - Link each Scroll Bar 

Insert a new column between columns B and C.  Put a new heading in the new column titled "Linked Weight."  We want to link each scroll bar to a metric so that we can use the scroll bars to change the weights.  To link a scroll bar to a value on a sheet, right click on the left-most scroll bar and select Format Control.  In the Cell link field, select the cell that will hold the current value of the scroll bar. You will also need to set Minimum Value to 1.


From the left-most scroll bar to the right, you'll want to link them to cells starting C3 all the way down to C7. Once the cells have been linked, go ahead and click the down arrows on each scroll bar. You should see the values change as you scroll down. This will also allow you to double-check that each scroll bar is associated with the correct cell.

Step 4 - Adjust Each Value

We have a small problem: the scroll bars increase their cell's values when scrolling down. While there's nothing wrong with that per se, it's counter intuitive to how we think. For our purposes, we'd like the action of scrolling up to actually increase the resulting value and scrolling down to decrease. So we need to adjust the values on the spreadsheet to reflect this preference.
Insert another column between C and D.  Name it "Adjusted Weights."  In each cell next to the Linked Weights, you will take the cell to its left and subtract 100 (the max value of the scroll bar).  You can do this with a formula like the one shown below.


Play around with the scroll bars. Note that the adjusted weights now increase and decrease intuitively.

Step 5 - Sum and Define Proportions

At the bottom of the Adjusted Weight column, add a SUM cell.

Now you will overwrite the values in your Final Weights column.  For each cell in Final Weight, you will divide the cell to its left (in the Adjusted Weight column) by the total sum you've just calculated.  Use the formula below as a guide.


At this point you're finished with Part 1. If you play around with the scroll bars, you will see that you can change the weight of one criteria at a time, while maintaining the proportionality of the others. The final scores update automatically! The scroll bars also adjust the location of the selector (that little gray bar) accordingly.

Limitations

As you may have already noticed, the scroll bars appear to have a limit. (Scroll one of them to its maximum value to see what I mean.) For some applications, this limitation isn't a real problem; but you may create a model where the "easy" method is not useful. Additionally, because we use formulas to derive the final weights, you can't type a desired weight into the Final Weights column without breaking part of the scroll bar mechanism. (But you can fix this problem with some VBA.)
In Part 2, we'll talk about putting this structure into a dashboard layout.

Download the file
One Way Sensitivity Analysis.xlsx

Change the Font Size, Color, and Style of an Excel Form Control Label

11
Anyone who has used a Form Control Label likely knows its limitations: you can't increase the font-size, -color, or style.  Below, you can see that these formatting items have been "grayed out" in the Font group on the Excel Ribbon.


To be sure, the Label control has received a lot of flack for these deficiencies.  A look through some Excel forums shows suggestions to use a TextBox shape or an ActiveX Label instead of the hapless Label control.It's a tragedy since the other form controls are lightweight and easy to use. Some forum posters even said Labels are best used to cover cells you don't want the user to click. So sad.   

But things are looking up.  I've since discovered you can take a boring Label Control from this...


...to this!



How?

As it turns out, Labels take on the text-font and -size features of a referenced cell.  So, to make my label look this this, I simply linked it to a pre-formatted cell, like G2, below.


In fact, this is the same mechanism to link a Textbox shape to a cell.  The difference here is that a Textbox can take an unformatted cell and apply new formatting on the front-end, when it's displayed to the user.  Above, we see that the cell must first be formatted, then linked.  In fact, whatever formatting exists in the cell when you first make the link, the label will maintain this format until a new link is created.  For example, if I were to change G2 to a black color and a smaller font, the label would not show these new changes (however, it would change its text if I changed the value in G2 to something else).  So to change the Label's formatting -- even when it's linked to the same cell -- you'll need to click the label, click the formula bar, and retype the cell link.  

Admittedly, everyone else might have already figured this one out.  However, I'm still very excited.  Don't get me wrong, Textbox Shapes are great, but having too many could become expensive on your spreadsheet, especially if you are constantly updating the screen (how many redraws can your computer handle before things start to slow?).  Labels, as Form Controls, inherently carry less bloat and overhead.  They're perfect for dynamic dashboards.  


Truncating Long Text to Fit into Cells

5
Have you had a list of names but found your cell width too small to show every name?  Take a look at this:


I had my nonexistent secretary print out this fake itinerary for me.  Nothing lines up neatly.  Look how some of my events overlap the cell boundary between columns B and C.  My 2012 End-of-world Steering Committee meeting on February 1st, 2013 goes long and is then cut-off by the date!

To fix this, you could have Excel automatically size Column B, but that's a bit unpredictable to have on a dashboard (what if other content is sized off the screen?).  We'll just have to accept that we can't show everything, but we can make it look neater.  We'll employ some type of text truncation method similar to what Microsoft uses to display the names of files in Windows Explorer: if the text to be displayed is greater than a certain character length, simply truncate and add a "...".

The "Original Recipe" Method

First thing we'll need to do is figure out how many characters we'll want to display before truncation.  There's really no way to do this without trial and error. But, to make life easier, we can use =LEN("Your Text Here") to return the length of your text; or, we can use something like  =LEFT(B3, 4) to return the first four characters of text in cell B3.  Keep trying until you find a good character length.  

Hopefully, you got a good handle on using LEN and LEFT above because we'll be using them from here on out.  Also, I'm going to use 25 characters as my desired character length before truncation.  Below I use  LEFT to pull the first 25 characters from each event name.


Now we'll need to know which names to add the "..." to.  Following ExcelHero's discussion on using IFs, we'll avoid using one here; not to worry, we don't really need it.

As it turns out, LEFT can take a zero value character length -- it just returns nothing.  So to have Excel automatically return what we want, we'll do this:

=LEFT("…",LEN(B3)>25)

Take a look at that second argument on the right.  It takes the length of our event name and tests if it's greater than our cutoff length of 25.  If it's less than 25, Excel will return a zero and display nothing.  If it's greater than the cutoff, Excel will return a 1 and display the first character in our text.  But there's something I found out while writing this tutorial, I expected Excel to only return one period ("."), but instead it returns all three ("...") even if you only put a 1 in on the right.  I'm guessing that the ellipses are treated as one character; however, I'm dubious that this works in every case on every computer, so to have your formula return three characters or zero, you'll simply change it to:

=LEFT("…",(LEN(B3)>25) * 3)

Now you'll need to concatenate both strings together using the concatenation operator, &.


Finally, as you can see in cell, H7, there is a space between the event name and the ellipses.  This is because the last character before the cutoff was a space.  To fix this, surround the first string formula with the TRIM function; this will automatically delete any leading or ending spaces.  

Putting it all Together

To finish, we'll combine all our steps into one formula, like so:

=TRIM(LEFT(B3,25)) & LEFT("…",LEN(B3)>25)

To get:
...mmmmmmuch better!

Download my example: Spillover Design Example.xlsx

A Dynamic Dashboard for Project Durations and Costs in Excel (part 2)

0
In the last post, A Dynamic Dashboard for Project Durations and Costs in Excel, we talked about using VLOOKUP as means to map references to their costs.  At the end of the post, I admitted that I didn't really like the solution.  Specifically, I didn't like how the user had to type in each reference manually and then go back and ensure their numbers were correct (for example, if execution is nine months long, the user would need to ensure they type the number 2, nine times).  In this post, we'll talk about how to automate this process.  When we're finished, you'll only need to type the number 9 into a box and the rest will update automatically.  

The Advanced Method

Step 1: Use the REPT formula
The REPT() formula (short for "Repeat") allows you to repeat a character a certain amount of times.  For example, if A1 has the formula =REPT("A", 6), then A1 will display the value "AAAAAA."  Now think about how that might be useful here.  We could simply input the number "6" for IT Services in the Execution phase and Excel will generate a reference string "222222."

Consider below:

In this case, =REPT(C$11$, C3) is telling Excel to repeat the value 1 (our reference to planning) a total of two times.  In other words,  =REPT(C$11$, C3) -> =REPT("1", 2) -> 11. (Remember, "11" is two 1's, not eleven.)

Step 2: Create the reference string
Now concatenate each string reference (using the concatenation operator "&") to form the entire reference string.

  
Step 3: Read from the reference string using the MID formula into your References Table
The MID formula allows you to take a string and read its characters starting from a specific position to a certain character length.  For example, =MID("Jordan",2,2) returns "or" since the first 2 tells Excel pull from the second character in "Jordan" and the second two tells Excel the amount of characters to return.  For our purposes, we'll only need to return one month at a time.  And since our reference table incidentally uses numbers for months, we'll reuse those numbers to tell the MID formula our desired character position.  When you supply a character position greater than the character length of the given text string, MID simply returns nothing.  

Above, we tell Excel to take the corresponding reference string for IT Services and use Month 1 to pull from position one in the reference string. Fill in the information going across, then down.  

Consider what we've done so far.  Now when you change the information in your Months in Step table, the reference strings change, which makes updates to the Reference Table automatically!
  

Step 4: Convert references to numbers in your Values Table
We have a small problem. Our Reference Table may be displaying the correct information, but it's actually displaying the information as text and not a number (this is because we used String formulas above, which work on and return text).  If we try to add the the numbers for the IT Services row in our Reference Table above, the result will actually be zero since, despite appearances, no numbers actually exist in the row.  Luckily, the fix is simple.  We'll use the VALUE() formula to convert the strings back to numbers.       

Step 5: Ditch VLOOKUP.  We don't need it.
VLOOKUP is best used to look up strings, not numeric values.  I've updated the look up table below.  Take note that each phase is actually intrinsically encoded: Planning is already in row 1; Execution in row 2; and Maturity in row 3.
In this case, we need only use the INDEX() formula.  The INDEX formula allows us to pull from a specific row and/or column in specified range.  For example, we could take the last column above and use the numbers in our Reference Table to identify the desired row.  Take a look below:

The Values Table uses 1 in the References Table to pull from the first row of our lookup. 

Step 6: Use IFERROR for months with zero values
Another small problem.  The INDEX formula above is reading in blank values and returning errors!  You'll need to tell Excel to return $0 for those months.  To do so, you'll use the IFERROR formula.  IFERROR works by attempting to execute a given formula; if the formula returns an error, IFERROR will direct Excel to return another value instead of an error.

Take a look: 



Step 7: Sum the Values Table, then graph


Summary
Hopefully that wasn't too bad.  I wanted to show how many different formulas can interact to create an automated dashboard.  Of course, you could tighten some formulas up.  For example, instead of using VALUES, you could simply use the "--".  And, you could even do away with the IFERROR by retooling your lookup table.  I'll leave that up to you.  


Something to try...
Use the reference table and conditional formatting to create a gannt chart!




We're still missing some desired functionality.  Wouldn't it be neat to be able to set the date when each project begins?  We'll talking about that in Part 3.  Don't miss the riveting, final conclusion!


Download the example file: Dynamic Duration Example.xlsx

A Dynamic Dashboard for Project Durations and Costs in Excel

3
Make sure to checkout A Dynamic Dashboard for Project Durations and Costs in Excel (part 2) for the example file!

Let’s say you are the manager of a portfolio of projects at your company.  While each project under your aegis is different, they have a few things in common; specifically – and for the sake of our example – they all go through (or, are currently in) three different phases, and each phase has a different cost per month, but the cost doesn’t differ between each project.  In our example, the phases are:
Phase Name Cost of each stage per month
1. Planning $250/month
2. Execution $500/month
3. Maturity $125/month
The idea is to capture both the cost in any given month and the overall cost over the life of the project.  For example, you have an IT Upgrades project in your portfolio.  You think that you will spend two months in Planning, nine months in Execution, and one month in Maturity after which the project will be closed.  Thus, the overall cost of your project is expected to be,
Planning @ two months: 2 months * $250 $/month  = $500
Execution @ nine months: 9 months * $500 $/month = $4500
Maturity @ one month: 1 month * $125 $/month = $125
Planning + Execution + Maturity =  $500 + $4500 + $125 = $5125
The problem is that each project is different.  One project might spend more time in the first phase than the other.  Moreover, for some projects you have a good idea of how long they will stay in each phase, and for some you are a bit less sure.  Boy, you say, wouldn't it be nice to change how long a project stays in each phase to compare costs.  Wouldn't it be nice to see it on a chart?  Let's see what we can do.

Using a VLOOKUP might seem like an obvious choice for our solution.  Here's how to do it.   

The Dynamic VLOOKUP Method

Step 1: Create the VLOOKUP table
Since you know there are three projects, you could encode ids into a lookup table numbers as follows.


Step 2: Create a Reference Table
The Reference Table is a time-series table that holds the numerical references to your VLOOKUP table.  If IT Services has two months of Planning, then the Reference Table will show two 1's in the first two months, respectively.

Step 3: Create a Values Table to map each reference to its monthly cost using VLOOKUP
Now, you'll make another table that is essentially a mirror image of your Reference Table. This table, however, maps each reference to the correct cost.  So, for Month 1 in the Values Table, VLOOKUP will use the corresponding reference (1) in the Reference Table to indicate the project is in the Planning phase and the associated cost is $250.


Step 4: Sum the Values Table, then graph


Summary
Our dynamic VLOOKUP() method works: the manager (that's us) can replace the values in the Reference Table to update how long a project stays in each phase.  We would simply repeat numbers in the Reference Table in the amount of months a project is in a particular phase.  Our Values Table automatically updates based on each change.



So here's the thing.  I don't like this method at all.  For one, we need a VLOOKUP in for every month, for every program.  Our example only displayed a few projects in a small time frame, but the real world might have many projects over many years!  That's a real problem because VLOOKUPs can become computationally expensive as our spreadsheet grows.

And there's another problem, too.  The manager – that's us, remember – must hand-jam the references in for every month. What if there are many years to account for?  We could Copy/Paste to make life easier, but this method is so very, very error-prone.  There should be a way for us to simply enter the months a project is in a given phase and have Excel automatically generate all the required reference information.

Let's talk about how to do that in the next post.

If you're having trouble with the work above, take some time to see if you can recreate your own version in Excel.  Even if you have followed everything so far, consider the VLOOKUP method and the importance of using numeric references.  They will play a very key role in part 2. 


-----


Now Available: A Dynamic Dashboard for Project Durations and Costs in Excel (part 2)