I think you need to use integration to solve this problem
Assume an elementary lenght dx on the rod, the charge dq = Q.dx/L
Potnetial dV of this elementary length at the point P is
dV = - k.dq/(d+x) = -k.Q.dx/L(d+x)
where k is a constant (=9x10^9 F/m)
You then have to integrate the equation from x= 0 to x = L