public void reduce(Text key, Iterable<Txn> values, Context context) throws IOException, InterruptedException { Txn max = new Txn(); for (Txn txn : values) { if (max.getAmount() < txn.getAmount()) { max = txn; } } outvalue.set( "Max amount = " + max.getAmount() + " & product = " + max.getProduct() + " & date = " + max.getTxnDate()); context.write(key, outvalue); }