If the light is indeed affected by the fuel level in the gas tank, then it is possible that you may have a small evaporative emissions system leak or a faulty component in the evap system.
Your car has a complicated system of plumbing , charcoal vapor storage canister, and solenoid valves that collect and store the fuel vapors from inside the gas tank so that they do not evaporate into the atmosplere. When conditions are right, the computer opens a valve to allow these collected vapors to be drawn into the engine to be burned.
Your BMW has what is known as an OBD-2 compliant engine management system; this means that the vehicle meets standards set by the federal government at the time the car was manufactured, which allow it to be legally sold in the US. One of the requirements of an OBD-2 compliant engine control system is that it must run self tests on emission control systems to verify that they are operational.
One of the self tests that the computer runs on your car is an operational test of the vapor storage system; when it runs this test the computer closes off the system by shutting all of the valves, and tehn opens the one through which the vapors are drawn into the engine. It leaves this valve open untill the entire vapor storage system, including the fuel tank, is under a vacuum, and tehn closes the valve again. Then, the computer monitors the system for vacuum decay using a pressure sensor mounted on the top of the gas tank. If vacuum is lost, the system fails the self test; this test is extremely sensitive; it is capable of detecting an extremely tiny leak equivalent to a hole .001 inch in diameter (the size of a pinhead). If any of the controlled devices do not respond properly, it also fails the self test. If the pressure sensor is not oeprational, it also fails the self test.
I am assuming that you are experiencing an evap system fault that is causing your light to come on when the self test fails, because of the fact that you say it does not happen when the tank is full. One of the requirements for the evap system monitor 9self test) to run is that the fuel level in the tank must be at a certain level (typically between 1/4 and 3/4 tank on most cars). If the tank is full, the self test does not run again untill the fuel level has dropped to a certain point. There really is nothing else on your car that can cause the check engine light to come on only at certain fuel tank levels, unless the fuel level sensor is faulty (which would cause the fuel gauge to not work).
To diagnose this type of problem is going to require some special test equipment; it is not really the type of problem you can accurately diagnose nor repair at home in the driveway. First, a scan tool will need to be connected to the car's data connector to see what fault codes and frozen data are stored in computer memory related to the fault; likely find a P0440, P0442, or other evap system related fault code stored there. Then, testing of the various components begins. using teh manufacturer's scan equipment yhe technician can oeprate teh various solenoids and monitor the pressure sensor reading to see if all of these components are operational. Also, a amoke generator machine is utypically used to inject a high density white smoke into all of the plumbing in the system (which is everywhere in the car) to check for tiny leaks.
If you want to try something, you can try installing a new gas cap to see if the problem goes away; a gas cap that is not sealing or venting properly creates a vapor leak in the system. If that does not correct the problem, you will need to take it in to a properly equipped repair shop to be diagnosed.