Hello, I hope the following is of assistance.
From the description you've given this is likely to be the start of an injector concern. The poor running and noise is due to the injector either spraying the incorrect pattern or incorrect amount of fuel (usually too much) which can be caused by a leaking injector.
The rattle is a diesel knock due to the uncontrolled burning of the excess fuel, at higher engine speeds the fuel is burnt faster and not as uncontrolled due to the engine needing more fuel which is why the noise disappears.
The cheapest option to start with would be to run some fuel additive through the system, try running the fuel low then putting the additive in the tank, also I wouldn't recommend Supermarket quality fuel.
If the car hasn't had a fuel filter for a while it would be good practice to replace this as the low pressure fuel system affects the quality of the high pressure fuel system.
If after these point then to confirm an injector concern you need to have a "leak off" check carried out on the injectors, this will identify if an injector is leaking fuel into the engine. If an injector is replaced then the new injector correction value needs entering into the engine management control module, this can only be done with suitable diagnostic equipment.
Start with these points let me know if I can assist further or if you have more questions regarding this and I'll reply as soon as I'm able to.