Answer
Electric Field at P\begin{align*}
E=\frac{1}{4\,\pi\,\epsilon_{0}}\,\frac{\lambda}{z}\bigg[\bigg(-1+\frac{z}{\sqrt{L^2+z^2}}\bigg)\hat{x}+\bigg(\frac{L}{\sqrt{L^2+z^2}}\bigg)\hat{y}\bigg]
\end{align*}
Work Step by Step
Here, we consider a point charge $dq$ on the line charge at a distance $x$ from the origin. This segment subtends an angle $\theta$ to the point P.
The two components of the electric field due to this point is given by \begin{align*}
e_x=-\frac{1}{4\,\pi\,\epsilon_{0}}\frac{dq}{r^2}\sin\theta\tag{1}
\end{align*}\begin{align*}
e_y=\frac{1}{4\,\pi\,\epsilon_{0}}\frac{dq}{r^2}\cos\theta\tag{2}
\end{align*}where, $r^2=x^2+z^2$, $\sin\theta=x/r$ and $\cos\theta=z/r$
To evaluate the electric field due to the line charge we integrate along the line from $x=0$ to $x=L$.
Thus we have from (1) -
\begin{align*}
E_x=-\int_{0}^{L} \frac{1}{4\,\pi\,\epsilon_{0}}\frac{\lambda dx}{r^2}\sin\theta\\
=-\frac{1}{4\,\pi\,\epsilon_{0}}\,\lambda\int_{0}^{L} \frac{ x}{[x^2+z^2]^{3/2}}dx\\
=-\frac{1}{4\,\pi\,\epsilon_{0}}\,\lambda\bigg[-\frac{1}{\sqrt{x^2+z^2}}\bigg]_{0}^{L}\\
=-\frac{1}{4\,\pi\,\epsilon_{0}}\,\lambda\bigg[\frac{1}{z}-\frac{1}{\sqrt{L^2+z^2}}\bigg]
\end{align*}Similarly, from (2) -
\begin{align*}
E_y=\int_{0}^{L} \frac{1}{4\,\pi\,\epsilon_{0}}\frac{\lambda dx}{r^2}\cos\theta\\
=\frac{1}{4\,\pi\,\epsilon_{0}}\,\lambda z\int_{0}^{L} \frac{ 1}{[x^2+z^2]^{3/2}}dx\\
=\frac{1}{4\,\pi\,\epsilon_{0}}\,\lambda\bigg[\frac{1}{z^2}\frac{x}{\sqrt{x^2+z^2}}\bigg]_{0}^{L}\\
=\frac{1}{4\,\pi\,\epsilon_{0}}\,\frac{\lambda}{z}\frac{L}{\sqrt{L^2+z^2}}
\end{align*}Thus, electric field
\begin{align*}
E=\frac{1}{4\,\pi\,\epsilon_{0}}\,\frac{\lambda}{z}\bigg[\bigg(-1+\frac{z}{\sqrt{L^2+z^2}}\bigg)\hat{x}+\bigg(\frac{L}{\sqrt{L^2+z^2}}\bigg)\hat{y}\bigg]
\end{align*}For $z\gg L$, the x-component of the the field tends to 0 and the expression reduces to
\begin{align*}
E=\frac{1}{4\,\pi\,\epsilon_{0}}\,\frac{\lambda}{z}\bigg[\frac{L}{z}\hat{y}\bigg]
\end{align*}which matches the expression for the electric field due to a point charge with charge $\lambda L$.