Plenty of vitamin D helps you absorb magnesium right. But some meds like diuretics can mess this up. So, can proton-pump inhibitors, leading to too little magnesium.