Most of the calculations above are exact at zero temperature, yet remain as good approximations for temperatures lower than the Fermi temperature. For other thermodynamics variables it is necessary to write a thermodynamic potential. For an ensemble of identical fermions, the best way to derive a potential is from the grand canonical ensemble with fixed temperature, volume and chemical potential µ. The reason is due to Pauli exclusion principle, as the occupation numbers of each quantum state are given by either 1 or 0 (either there is an electron occupying the state or not), so the (grand) partition function  can be written as
where ,  indexes the ensembles of all possible microstates that give the same total energy  and number of particles ,  is the single particle energy of the state  (it counts twice if the energy of the state is degenerate) and , its occupancy. Thus the grand potential is written as
The same result can be obtained in the canonical and microcanonical ensemble, as the result of every ensemble must give the same value at thermodynamic limit . The grand canonical ensemble is recommended here as it avoids the use of combinatorics and factorials.
As explored in previous sections, in the macroscopic limit we may use a continuous approximation (Thomas–Fermi approximation) to convert this sum to an integral:
where  is the total density of states.