The present invention provides a novel compound having a GPR40 receptor function modulating action, which is useful as an insulin secretagogue, a drug for the prophylaxis or treatment of diabetes and the like.A compound represented by the formula (I)wherein each symbol is as defined in the specification, a salt thereof and a prodrug thereof have unexpectedly superior GPR40 receptor agonist activity and also show superior properties as a pharmaceutical product, such as stability and the like. Thus, they can be safe and useful drugs for the prophylaxis or treatment of GPR40 receptor related conditions or diseases in mammals.