We consider a best discrete approximation problem in the setting of tropical (idempotent) algebra dealing with the theory and application of semirings and semifields with idempotent operations. Given a set of input-output pairs of an unknown function defined on a tropical semifield, the problem is to determine an approximating rational function formed by two Puiseux polynomials as numerator and denominator in the function. With specified numbers of monomials in both polynomials, the approximation aims at evaluating the exponent and coefficient for each monomial in the polynomials to fit the rational function to the given data in the sense of a tropical distance function. To solve the problem, we transform it into approximation of a vector equation with unknown vectors on both sides with one side answered to the numerator polynomial and the other side to the denominator. Each side of the equation involves a matrix with entries dependent on the unknown exponents, multiplied by the vector of unknown coefficients of monomials in the corresponding polynomial. We propose an algorithm that constructs a series of approximate solutions by alternatively fixing one side of the equation to the already found result and leaving the other intact. The obtained equation is first approximated with respect to the vector of coefficients, which results in a vector of coefficients and approximation error both parameterized by the exponents. Furthermore, the values of exponents are found by minimization of the approximation error, using an optimization procedure that is based on an agglomerative clustering technique. To illustrate applications, we present results for approximation problems formulated in terms of max-plus algebra (a real semifield with addition defined as maximum and multiplication as arithmetic addition), which correspond to ordinary problems of piecewise linear approximation of real functions. As our numerical experience shows, the proposed algorithm converges in a finite number of steps and provides a reasonably good solution to approximation problems considered.