The solution is simple. First of all, try to figure out what diagonal means compared to forwards/backwards and left/right respectively. Once you did that, you will very likely know how to make your idea work.
Since floats are often dangerous in regards to precision, it is better not to check for exactly 0. When you use a gamepad, you often don’t get exactly 0 even if you don’t move the stick.
For this reason, it is advisable check against a threshold. In this case, I would simply check the absolute value. Unity has got a method for that: Mathf.Abs(xValue). And then you could check: Mathf.Abs(xValue) > 0.01f, where 0.01f is my threshold. Of course, you could use another value.