In mid-May I will be taking a trip through Norway and doing NiN in reverse. I'll be in Balestrand for 2 nights before departing for Oslo. We will take the ferry to Flam then the train to Myrdal...and then onward to Oslo. Given that it is May should I try to but tickets ahead of time or will there likely be plenty of availability. I'm hoping that it's still not the busy season and I'll have the ability to be flexible with my travel plans.
I am doing a similar trip in May. Checked availability a month+ ago and there was good availability at the time. Haven't booked anything yet and haven't checked since. I'm working through a travel agent and she hasn't indicated any issues (although she hasn't booked anything for me either). I plan on going full-bore into making bookings this week.
I got the following link from my hotel in Balestrand. I was able to book my ferry tickets successfully. Good luck and enjoy your trip
https://www.norled.no/en/fjordcruise/sognefjorden-bergen-to-flaam/