From: Adam Akhtar Date: 2008-08-20T20:18:15+09:00 Subject: Re: array of hashes - need to iterate and calulate stats but how Thanks for the response, your solution would be great but the problem is i cant use a hash to store the output as I need to store more than two values. I need to have model number, total listed, total sold and finaly the sell through rate based on the previous two numbers. Ive tried to rejig teh general jist of your approach but couldnt. Heres my very rough solution. Surely theres a more elegant way to this number_listed = 0 number_sold = 0 current_model = item_info[0][:unique_identifier] item_info.each do |item| if current_model != item[:unique_identifier] result = {unique_identifier => current_model, :total_listings => number_listed, :total_sold => number_sold, :str => number_sold/number_listed*100.00} number_sold = 0 numbler_listed = 0 unique_identifier = item[:unique_identifier] end number_sold += if item[:did_it_sell] number_listed += end -- Posted via http://www.ruby-forum.com/.