Retained earnings aren't "calculated" in the trial balance (the trial balance is simply a snapshot of accounting info). The accumulated past profits which have been retained (rather than paid out as dividend) are "shown" in the trial balance.