This could be due to lack of good natural light and under watering. Sometimes artificial direct lamp light can keep plants from flowering especially if the lamp produces a lot of heat. That may be why you haven't seen many blooms. Bright indirect light is best.
Water the cactus thoroughly when the soil is dry. If possible, try keeping it in a cool room around 60 degrees. The temperature will help set buds. A cooler room should also keep the flowers blooming for longer.