In analogy with electromagnetic networks which connect multiple input-output ports, metasurfaces can be considered as multi-port devices capable of providing different functionalities for waves of different polarizations illuminating the surface from different directions. The main challenge in the design of such multichannel metasurfaces is to ensure independent and full control of the electromagnetic response for each channel ensuring the fulilment of the boundary condition at the metasurface. In this work, we demonstrate that by properly engineering the evanescent fields excited at each port (that is, for all possible illumination directions), it is possible to independently control the reflection or transmission for all different illuminations. We develop a fully analytical method to analyze and synthesize general space-modulated impedance metasurfaces, engineering strong spatial dispersion. This method, combined with mathematical optimization, allows us to find a surface impedance profile that simultaneously ensures the desired electromagnetic responses at each port. We validate the technique via the design of phase-controlled multichannel retroreflectors. In addition, we demonstrate that the method is rather powerful in the design of other functional metasurfaces such as multifunctional reflectors and multichannel perfect absorbers.