fuels = {"Coal", "Gas", "Hydro", "Nuclear", "Oil", "Other", "Wind"};
n = 50;
Generate random test data and Export
as Excel document
SeedRandom[0]
Export["data.xls",
Transpose[{RandomChoice[fuels, n], RandomReal[{0, 5000}, n]}]];
You are starting here. Import
data from Excel document
data = Import["data.xls"][[1]];
Total
by fuel
EDIT: Added clean-up for blank values (issue identified by Mike Honeychurch)
summary = Sort[{#[[1, 1]], Total[#[[All, 2]]]} & /@ GatherBy[data, First]]/.
Plus[x_?NumericQ, _. * _String] :> x
(* {{"Coal", 14230.6}, {"Gas", 11889.7}, {"Hydro", 20580.6}, {"Nuclear",
13221.4}, {"Oil", 14643.9}, {"Other", 17112.9}, {"Wind", 15121.8}} *)
EDIT 2: Added table
summary // Prepend[#, Style[#, Bold, 14] & /@ {"Fuel", "Power"}] & //
Grid[#, Frame -> All] &