  The weak itinerant magnetic properties of $A_2$Ni$_7$ compounds with $A$ =
{Y, La} have been investigated using electronic band structure calculations in
the relation with their polymorphic crystal structures. These compounds
crystallizes in two structures resulting from the stacking of two and three
blocks of [$A_2$Ni$_4$ + 2 $A$Ni$_5$] units for hexagonal $2H$-La$_2$Ni$_7$
(Ce$_2$Ni$_7$ type) and rhombohedral $3R$-Y$_2$Ni$_7$ (Gd$_2$Co$_7$ type)
respectively. Experimentally, $2H$-La$_2$Ni$_7$ is a weak itinerant
antiferromagnet whereas $3R$-Y$_2$Ni$_7$ is a weak itinerant ferromagnet. From
the present first principles calculation within non-spin polarized state, both
compounds present an electronic density of state with a sharp and narrow peak
centered at the Fermi level corresponding to flat bands from $3d$-Ni. This
induces a magnetic instability and both compounds are more stable in a
ferromagnetic (FM) order compared to a paramagnetic state ($\Delta E \simeq$
-35 meV/f.u.). The magnetic moment of each of the five Ni sites varies with
their positions relative to the [$A_2$Ni$_4$] and [$A$Ni$_5$] units: they are
minimum in the [$A_2$Ni$_4$] unit and maximum at the interface between two
[$A$Ni$_5$] units. For $2H$-La$_2$Ni$_7$, an antiferromagnetic (AFM) structure
has been proposed and found with an energy comparable to that of the FM state.
This AFM structure is described by two FM unit blocks of opposite Ni spin sign
separated by a non-magnetic layer at z = 0 and $\frac12$. The Ni ($2a$) atoms
belonging to this intermediate layer are located in the [La$_2$Ni$_4$] unit and
are at a center of symmetry of the hexagonal cell ($P6_3/mmc$) where the
resultant molecular field is cancelled. Further non-collinear spin calculations
have been performed to determine the Ni moment orientations which are found
preferentially parallel to the $c$ axis for both FM and AFM structures.
