NSB, Norwegian State Railways, runs daily services between Oslo and Bergen. The train from Oslo to Myrdal takes around 4.5 hours. The train from Bergen to Myrdal takes around 2 hours. At Myrdal, you can change to the Flåm Railway. This will take you down to Flåm in one hour. See train times and fares here www.nsb.no.
To book tickets for the Flåm Railway, click here.