Monday, October 13, 2014

Automatic classification based on a table of relationships or typology

Last time, I talked about using VLOOKUP to automatically assign the grade equivalent of a raw score. This time, we will use VLOOKUP to classify non-numerical items.

Let's say that you have a table as follows:

Power PlantCapacity (In MW)Energy ResourceFossil or Renewable?
APEC50Coal
Bacman130Geothermal
Bajada DPP58.7Oil Based
Bakun70Hydroelectric
Bangui Wind Power33Wind
Botocan22.8Hydroelectric
Calaca600Coal
Calibu DPP30Oil Based
Caliraya35Hydroelectric
Casa Bioenergy15Biomass
Casecnan (NIA)165Hydroelectric
CEDC Coal246Coal
CEMEX66Oil Based
Crystal Sugar35.9Biomass
DESCO Natural Gas1Natural Gas
First Farmers21Biomass

So you want the spreadsheet to enter in the fourth column if the power plant is renewable or fossil fueled. Assuming you know that  fossil means power plant using coal, oil-based or natural gas, and renewable uses everything else, you can create the following reference table (again, I recommend that you use a separate sheet within the same file):

BiomassRenewable
CoalFossil
GeothermalRenewable
HydropowerRenewable
Natural GasFossil
OilFossil
SolarRenewable
WindRenewable

You want to tell the program to do the following in your list of power plants:
  1. Search for the type of energy resource in the list of power plants in the reference table, then
  2. Enter the corresponding type of energy resource.
To do that, you type the following in the cell in the "Fossil or Renewable?" column:

=VLOOKUP(Cell_in_EnergyResourceRow, Range_of_ReferenceTable, Column_Number_of_Types_in_ReferenceTable)

Just do this in one column, change the references in the reference table to absolute, then copy the formula to the other cells in the "Fossil or Renewable?" column.

For reference, you can see this file.

Note: Your reference table may have multiple columns, because something may be classified in more than one way. For example, the power plant may be classified also based on if the energy resource if clean (all renewable energy plus natural gas) and traditional. To do this, just add the third column in the reference table, use VLOOKUP, and in the list, indicate the third column as the column number to be used.

No comments:

Post a Comment