This paper studies a portfolio allocation problem, where the goal is to prescribe the wealth distribution at the final time. We study this problem with the tools of optimal mass transport. We provide a dual formulation which we solve by a gradient descent algorithm. This involves solving an associated HJB and Fokker--Planck equation by a finite difference method. Numerical examples for various prescribed terminal distributions are given, showing that we can successfully reach attainable targets. We next consider adding consumption during the investment process, to take into account distribution that either not attainable, or sub-optimal.