In a method and magnetic resonance system to determine a flow coding for a flow measurement with the magnetic resonance system, in order to determine the optimal flow coding, a flow pre-measurement with multiple different flow codings is conducted within a slice within a body to be examined, each of these codings allowing flow velocities to be detected with a sensitivity dependent on the respective coding. A velocity distribution of the non-slice-location-specific flow velocity values is generated from all of the results of this flow pre-measurement by a common Fourier transformation. The optimal flow coding for the flow measurement is then determined based on this velocity distribution.