Hexagonal La2Ni7 and rhombohedral Y2Ni7 are weak itinerant antiferromagnet (wAFM) and ferromagnet (wFM), respectively. To follow the evolution between these two compounds, the crystal structure and magnetic properties of A2B7 intermetallic compounds (A = La, Y, B = Ni) have been investigated combining X-ray powder diffraction and magnetic measurements. In the present study, the La2-xYxNi7 intermetallic compounds with 0 ≤ x ≤ 1 crystallize in the hexagonal structure (Ce2Ni7-type) with Y preferentially located in the [AB2] units. The compounds with larger Y content (1.2 ≤ x < 2) crystallize in both hexagonal and rhombohedral (Gd2Co7-type) structures with a progressive substitution of Y for La in the A sites belonging to the [AB5] units. Y2Ni7 crystallizes in the rhombohedral structure only. The average cell volume decreases linearly versus Y content, whereas the c/a ratio presents a minimum at x = 1 due to geometric constrains. The magnetic properties are strongly dependent on the structure type and the Y content. For x ≤ 1, the magnetic order oscillates between wAFM and wFM depending on the Y content and applied magnetic field. All the compounds with x > 1 are wFM with TC = 55 K. In addition to the experimental studies, first principles calculations using spin polarization have been performed to interpret the evolution of both structural phase stability and magnetic ordering for 0 ≤ x ≤ 2. Magnetic instability is related to the presence of a sharp and narrow peak in the density of state near the Fermi level. A stable AFM structure has been found for hexagonal La2Ni7. It explains how the magnetic order is driven by the geometric constrains induced by the stacking of [AB2] and [AB5] layers.