Ads 468x60px

Wednesday, November 28, 2012

Extract data using Advanced Filter and VBA

Extract data using Advanced Filter and VBA:
In this post we will learn how to use the Advanced Filter option using VBA to allow us to filter our data on a separate sheet. This has been requested by a lot of our readers and here is how we will use them.
Filter records using advanced filter and vba

What we need to get this done.

1. Some data that we need filtering on.

2. Define what options we need as drop down lists

3. A cup of coffee

In the sample data, I have defined 4 options to be available as drop down list; this has been done by creating a new sheet called as “Master”. I then copied the existing columns data into this sheet and used the Remove Duplicates feature to get the unique list of items that was required for the drop downs.

The named ranges were created using the INDEX function as shown below

Named Range Formula
prd =Master!$A$2:INDEX(Master!$A:$A,COUNTA(Master!$A:$A))
rgn =Master!$B$2:INDEX(Master!$B:$B,COUNTA(Master!$B:$B))
cust =Master!$C$2:INDEX(Master!$C:$C,COUNTA(Master!$C:$C))
agnt =Master!$D$2:INDEX(Master!$D:$D,COUNTA(Master!$D:$D))
Now we need to setup the sheet where we need the filtered data to be displayed. Headings were put in cells B5 to B8 and the drop down (using the Data Validation—List) feature was put in cells C5 to C8. Now we need to create or criteria fields in the RawData sheet, this is a requirement and cannot be any place else. When you use the Advanced Filter dialog box and try to place the output onto another sheet Excel will display a message saying “You can only copy data to the Active Sheet”. We will overcome this limit by using VBA and telling Excel where to put the filtered data. I used the cells M1 to P1 to define the headings and cells M2 to P2 to get the actual options from the “Filter Sheet”
Cells Formula
M2 =Filter!C5
N2 =Filter!C6
O2 =Filter!C7
P2 =Filter!C8

Macro to run advanced filter and extract data



Sub FilterData()

Sheets("Filter").Select

Range("B10").Select

Range(Selection, Selection.End(xlToRight)).Select

Range(Selection, Selection.End(xlDown)).Select

Selection.Clear

Sheets(“RawData”).Range(“Table1[#All]“).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _

Sheets(“RawData”).Range(“M1:P2″), CopyToRange:=Sheets(“Filter”).Range(“B10″), Unique:=True
Columns.AutoFit

Range(“B10″).Select

End Sub
First we ensure the current filtered data (in any) is cleared out before we run the code again and then we get the new filtered data from cell B10 onwards. Now let’s understand the actual code that filters our data here.


Sheets("RawData").Range("Table1[#All]").AdvancedFilter

Action:=xlFilterCopy,

CriteriaRange:=Sheets("RawData").Range("M1:P2"),

CopyToRange:=Sheets("Filter").Range("B10"),

Unique:=True


We converted our raw data into an excel table (Structured Reference Structured Reference), by doing this we no longer need to know how many rows our data actually goes down to, the “Table1[#All]” takes care of that for us.
We also need to specify that our data is in another sheet and we are trying to run Advanced Filter on that data range, this is done using the first line ” Sheets(“RawData”).Range(“Table1[#All]“).AdvancedFilter “.
Next we specify the action that we need which is Copy in our case, the other option is “xlFilterInPlace” which would filter right on our data itself.
Then we have specified the Criteria Range (which needs to be on the same sheet where the data is).
And finally we have specified where the output has to be sent to by using : “CopyToRange:=Sheets(“Filter”).Range(“B10″)”
We have also made sure that only Unique records are returned to us by turning Unique:=True.

Download Advanced Filter Demo File

Click here to download the demo file & use it to understand this technique.

Do you use Advanced filters to extract sub-sets of data?

Advanced filters are very powerful and very simple to setup. I use them often to quickly extract what I want.
What about you? Do you use them often? Please share your experiences, techniques & ideas using comments.

Learn more about extracting / consolidating data using VBA

Data extraction and consolidation are one of the most common activities done by reporting professionals & analysts. No wonder we speak about these areas a lot here too. Please check out these pages to learn more:
Want to lean more? Consider joining our VBA Classes
If you would like to learn more about VBA programming, Excel automation, creation of user forms, manipulating data in Access thru Excel etc., consider joining our online VBA Classes. This step-by-step program helps you become awesome in VBA.
Click here to know more & Join our classes.

Monday, November 26, 2012

Excel Links – Lets meet in Chennai this Sunday edition

Excel Links – Lets meet in Chennai this Sunday edition:
Hi readers…
I am in Chennai this week, conducting in-house training at Renault Nissan on Advanced Excel. As I am busy teaching Excel & making young graduates awesome in it, I will not be able to write much on the blog. But don’t worry. We have some great articles coming up from Hui & other guest authors.

Coffee & Conversations for Chandoo.org Chennai Clan

If you are in Chennai, love Excel & coffee, you are in for a treat. This Sunday (2nd December), join me for hot coffee in the morning (8-10AM).
RSVP using below links.
Yes I want to join this meet up (alternative link: Facebook Event).

Moving on to Excel links..,

Show sparklines for hidden data too

Debra tells how to setup sparklines for data that is in hidden cells. If you have not tried sparklines, you are missing out on one of the most fun, easy to use charting feature in Excel 2010 / 2013. Check out this tutorial to get started.
Interactive tooltips in Excel

Robert shares an elegant mechanism to display rich, interactive tool tips in Excel. Very useful for data heavy dashboards & reports.
Book Recommendation: Power Pivot for Analysts

I just finished reading Bill Jelen’s Power Pivot for Data Analyst, an excellent book for those of us getting started with PowerPivot. It is easy to read with insightful, explanative & humouros commentary of Bill. Make sure you download the example workbooks and practice more.
Format Charts Quickly

From our archives, this one shows you how to quickly format charts. Works in Excel 2007 and above.

Have a good week ahead

And oh yeah, if you are in Chennai, don’t forget the meetup. Make sure you RSVP using above links so that I can send you venue & time details.



Financial Ratios – Cappuccino or Latte?

Financial Ratios – Cappuccino or Latte?:
This is a guest article by Paramdeep, a financial modeling expert & teacher.

A Quick Question for you!

Don the hat of a financial wiz today. What I have for you are the financials of two companies: Cappuccino and Latte – Two dot com companies (Sometimes they also make revenues ;-) )
Financials
(Remember, when they make money, they make it fast!)
Which is better – Cappuccino or Latte? ( Hint: It’s a trick question! ;-) )
It may seem obvious that Latte is performing better (Higher the revenue, the better the performance!). Sometimes a single source of data does not speak the full story!

What the data does not speak about?

Absolute values of Net Income or Revenue can give confusing signals. Absolute numbers can vary based on Size of Firm in terms of Invested Capital, Sales, Net Income, etc. The data needs to be looked at, in a holistic manner. For example, Ratios get you the common sized numbers (That’s a jargon for saying that for USD 1 of denominator, what is the numerator that I make).

What can reveal the Story?

We can use Ratio Analysis tool to make you a better Whiz at finance. So what ratios could be useful and what do they imply?
Net Profit Margin (NPM)
  • How to Calculate: Net Income/ Revenue
  • What does it measure: Net Profit Margin measures how much out of every dollar of Sales a company actually keeps in earnings
What other Ratios can be useful?
Return on Equity
  • How to Calculate: Net Income/ Equity Invested
  • What does it measure: Return on Equity measures the efficiency with which stockholder’s investment has been used.

More Information Required to Assess the Performance

Let’s say I had given you more information (Now don’t complain – If you had asked for it earlier, I would have happily given it to you!)
Now, check Net income and Equity investment of both these companies given in table below.
Financials_2

Calculating in Excel

Simple. All you need to do is divide the Net Income by revenue and divide the Net Income by Equity investment. Excel makes the calculations a breeze!
Financial_Particulars
Quick Tip: To quickly convert numbers into percentage in Excel, use the Shortcut: Ctrl + Shift + 5 (Ctrl + %)
Particular_financials_2
And bang! You get the correct formatting!

Quick Word on Analysis

Net profit margin for Cappuccino is 15% and for Latte it is 11%. It means for every USD 1 of Sales, Cappuccino makes 15 Cents as earnings, whereas Latte gets only 11 Cents. That means tomorrow if the revenue of Cappuccino and Latte increase by the same dollar amount, Cappuccino would outperform Latte!
Company with high profit margin with high investment may not be returning a great amount to investors. Firm with low profit margin may have required a very small investment so that it proves highly profitable to those who invest in it.
To assess the return to the shareholders, we can look at Return on Equity (RoE) ratio. RoE for Cappuccino is 18% and for Latte it is 13%. It indicates that for every USD 1 of equity invested, Cappuccino shareholder’s gets 18 cents, whereas Latte shareholder’s gets only 13 cents.
If you would have had complete information, you could have said Cappuccino is better! :-)

Templates to download

I have created a template for you, where the subheadings are given and you have to link the model to get the cash numbers! You can download the same from here. You can go through the case and fill in the yellow boxes. I also recommend that you try to create this structure on your own (so that you get a hang of what information is to be recorded).
Also you can download this filled template and check, if the information you recorded, matches mine or not! :-)

Next Steps

This series gives you a flavor of some basics concepts on finance that are very important for professionals engaged in non-finance activities as well. We are launching a course on finance for non-finance people and would be using excel extensively to practically illustrate the concepts. This would be interesting to you, if you are in any of the professions like marketing, project management, lawyer, IT, entrepreneurship and want to learn more on finance
If you are interested in getting more information on the course on finance for non-finance, please join our newsletter
For any queries regarding the cash impact or financial modelling, feel free to put the comments in the blog or write an email to paramdeep@edupristine.com

Project Portfolio Dashboard in Excel [Part 2 of 2]

Project Portfolio Dashboard in Excel [Part 2 of 2]:
In this 2 part tutorial, we will learn how to design a project portfolio dashboard. Part 1 discussed user needs & design. Part 2 will show you Excel implementation.
Project Portfolio Dashboard Pack is now available.

Click here to get your copy.

Background: Designing a Project Portfolio Dashboard

As discussed in part 1, the biggest challenge when it comes to designing project portfolio (program) level dashboards is that, End users want it very concise yet powerful.
We have identified important needs of our end users & come up with a mock up design that meets all these. Refer to part 1 for that discussion.

Final Implementation – Project Portfolio Dashboard

First lets take a look at the finalized dashboard implementation. Click on it to enlarge.
Project Portfolio Dashboard using MS Excel - Download now

Construction of Project Portfolio Dashboard

Design philosophy for the dashboard

First let us understand the design philosophy for this dashboard, because that is what drives all the Excel work. Here is a mind map that explains how I approached the design of this dashboard.
Designing Project Portfolio Dashboard - Mindmap

Data Entry

Majority of data in this dashboard is captured using Excel Tables. This has several advantages:
  • Users can easily add more rows of data without worrying about the formulas.
  • Formulas are self-explanatory, thanks to structural references.
  • Data entry is easy, thanks to banded rows, headers & table styles.
There are 6 important tables:
  1. High level project details table
  2. People details table
  3. Each project’s plan details go in to a table, named plan1, plan2…plan10
  4. Risks table
  5. Issues table
  6. Holidays table

Calculations

Explaining each and every formula in this would take us until next years Christmas. So I will highlight key formulas & challenges faced:
Fetching relevant project plan from all plans:
This was one of the trickiest things. Since each plan has its own table, getting selected project’s table is necessary to drive all calculations. This is how its done.
  1. Define lstPlans as a list of all tables =plan1,plan2…,plan10
  2. Use INDEX to fetch one of the tables from this array like this =INDEX(lstPlans, activity-row-number, column-number, plan-number)
Sorting Projects:
This is done using 3 steps:
  1. Extract relevant data for all projects based on sort criteria (for example, sort by done % means we need done %s for all projects)
  2. De-duplicate this data by adding a small running fraction to them
  3. Sort using RANK formula
This is essentially same technique Robert taught us in 2008 in KPI Dashboards article.
Showing Daily, Weekly or Monthly Gantt view:
This is achieved by using below logic:
  1. For Daily gantt, see if date in the column is between start & end dates (more: Between formula in Excel)
  2. For Weekly gantt, see if the week start & week end in the column fall between start dates’ week start and end dates’ week end. (more: Date overlap in Excel)
  3. For Monthly gantt, see if the month’s start & end in the column fall between start dates’ month start and end dates’ month end.
Other important formulas:
  • WORKDAY for all date related calculations so that holidays & weekends are omitted
  • INDEX for all dynamic ranges so that dashboard remains responsive.
  • No UDFs .
  • Very few array formulas so that users can understand what is going on.
  • Structural references as much as possible so that formulas are readable, editable & dynamic. [More on Excel tables]
  • Used lots of named ranges to keep formulas readable.

Dashboard Display

This dashboard display follow box layout with simple colors, easy charts, picture links & lots of conditional formatting goodness.
To understand the important Excel features used in this, see below image & following list.
Excel features used in Project Portfolio Dashboard - Explanation
  1. Hyperlinks: for accessing other parts of the workbook & data
  2. Boxes & Text boxes: to show data & provide layout.
  3. Thermometer chart to show budget vs. actual performance
  4. Simple Column charts to show distribution of values
  5. Combo boxes for selecting sort & view options
  6. Scroll bars for seeing more
  7. Conditional formatting for icons, highlighting & gantt chart
  8. Picture links to embed project summaries & gantt chart views
  9. Option buttons to select a particular project

Dashboard Usability

Color Scheme:
Use default Office 2007 (2010) theme. This provides very good contrast, excellent color mix & does not surprise many people.
Fonts:
Only 2 fonts are used thru out dashboard. Franklin Gothic Book for content & Franklin Gothic Demi for headers.
Fonts used in Project Portfolio Dashboard
These fonts are specified in dashboard’s theme so that they apply by default when opened in any computer.
Printable:
The dashboard is optimized for print. All form controls & links are disabled for printing. This ensures that you get a clean printout with just data & charts.
Tip: You can disable printing for any object by right clicking > format > properties and un-checking the print option.
Macros:
Since the workbook uses macros, I have added a warning message that shows up when macros are disabled. A technique I picked up from Mike Alexander.

How this dashboard works [Video]

Since all this explanation might not do justice to the work, I made a short video [12 mins] explaining how the dashboard works. See it below:

Download Project Portfolio Dashboard

Now you can get this and 4 other project portfolio management templates (including simplified portfolio dashboard, time line chart, gantt chart templates). All these files are easy to use, beautiful to present, fully customizable, unlocked and designed to make you awesome.
Click here to get a copy of the project portfolio portfolio dashboard.

How do you like this dashboard?

I really enjoyed making this dashboard. It was challenging & entertaining experience for me. I think the final workbook summarizes performance of a bunch of projects in a concise yet powerful way.
What do you think? Do you like this dashboard? Do you often work with project portfolio / program level dashboards? How do they look and behave? Please share your feedback, suggestions & ideas using comments.

Thank you for your suggestions & feedback

Thanks everyone who sent suggestions thru emails & comments. I feel very happy about the way this dashboard has turned out. Thanks for your continued support for Chandoo.org.
PS: Go ahead and pick up Project & Portfolio Management template pack today, because you want to be awesome.

Saturday, November 17, 2012

Project Portfolio Dashboard – Official Trailer

Project Portfolio Dashboard – Official Trailer:
Behold, here is the official trailer for our Project Portfolio Dashboard, releasing worldwide on 19th November (Monday), 2012.



[Watch it on our Youtube Channel]

What is Project Portfolio Dashboard?

Few days ago, we learned how to design a project portfolio dashboard. The next part (which will be posted on Monday) talks about how to create this dashboard using Excel.
Starting 19th November, you can purchase this dashboard and use it for tracking multiple projects. More details on Monday. Got to catch some sleep now :)

Tuesday, November 13, 2012

Happy Diwali [Animated Chart inside]

Happy Diwali [Animated Chart inside]:
My heartiest Diwali wishes to  all our readers.
The spirit of Diwali is to encourage people to spread joy, celebrate good things and discard darkness (evil). These ideas are universal. So let me wish you a very happy Diwali.
Diwali, festival of lights, is celebrated in the month of October / November. It is one of my favorite festivals since childhood. A time when all family members get together, celebrate all the good in their life, laugh and light a few fire crackers (fire works).
This year, our kids (Nishanth & Nakshatra) too are excited about the festival. They are eager to light diyas (small lamps), watch the fire works and enjoy. Naturally I do not feel like opening Excel.
But then…,
Sometime during my morning coffee, I thought “hey, why not create a small Diwali greeting using Excel?
So here we go.

Happy Diwali Animated Chart

See the chart demo here:
Happy Diwali Animated Chart in Excel - Demo

How does it work?

Well, that is for you to figure out. I am too lazy to lift the full veil for you. But here are some clues:
  • The greeting is just a bubble chart
  • Few bubbles are for the tinkling stars
  • Few more for the diyas
  • Background VBA just modifies the bubble size thru a simple scaling factor
  • For more, see this: Animated Hurricane Sandy Chart

Download and play with this

Click here to download the animated Diwali greeting & play with it. Examine the code & formulas to understand how this is created.

Do you like this Chart?

Do you like this chart? Area you able to figure out how this is made? Please share your ideas & suggestions using comments.
If you are feeling adventurous, create your own animation (using Excel of courses) and share it with us all :)

Want to create such animated charts – Read on

Animation is a powerful way to attract user attention. Check out these pages to learn more.

Want more? Consider our VBA course

If you want to learn more about animation & other VBA techniques, consider joining our online VBA classes. In a few weeks, you can master all aspects of Excel VBA & Macros.
Please Click here to know more & join us.