Large-eddy simulations of a clear convective boundary layer (CBL) and a stratocumulus-topped boundary layer are studied. Bottom-up and a top-down scalars were included in the simulations, and the principle of linear superposition of variables was applied to reconstruct the fields of any arbitrary conserved variable. This approach allows a systematic analysis of countergradient fluxes as a function of the flux ratio, which is defined as the ratio between the entrainment flux and the surface flux of the conserved quantity. In general, the turbulent flux of an arbitrary conserved quantity is counter to the mean vertical gradient if the heights where the vertical flux and the mean vertical gradient change sign do not coincide. The regime where the flux is countergradient is therefore bounded by the so-called zero-flux and zero-gradient heights. Because the vertical flux changes sign only if the entrainment flux has an opposite sign to the surface flux, countergradient fluxes are predominantly found for negative flux ratios. In the CBL the flux ratio for the virtual potential temperature is, to a good approximation, constant, and equal to -0.2. Only if the moisture contribution to the virtual potential temperature is negligibly small will the flux ratio for the potential temperature be equal to this value. Otherwise, the flux ratio for the potential temperature can have any arbitrary (negative) value, and, as a consequence, the fluxes for the potential temperature and the virtual potential temperature will be countergradient at different heights. As a practical application of the results, vertical profiles of the countergradient correction term for different entrainment-to-surface-flux ratios are discussed.