We introduce a fermionic formula associated with any quantum affine algebra Uq(X (r) N ). Guided by the interplay between corner transfer matrix and Bethe ansatz in solvable lattice models, we study several aspects related to representation theory, most crucially, the crystal basis theory. They include one dimensional sums over both finite and semi-infinite paths, spinon character formulae, Lepowski-Primc type conjectural formula for vacuum string functions, dilogarithm identities, Q-systems and their solution by characters of various classical subalgebras and so forth. The results expand [HKOTY1] including the twisted cases and more details on inhomogeneous paths consisting of non-perfect crystals. As a most intriguing example, certain inhomogeneous one dimensional sums conjecturally give rise to branching functions of an integrable G