Ask most people to name an important nutrient that's lacking in the American diet, and magnesium would probably not be in the top few answers.

But nearly half of all Americans—and 70 to 80 percent of those over age 70—fail to meet their daily magnesium needs. (Women should be getting 320 milligrams per day; men, 420 mg.) Long-term, not enough magnesium can lead to appetite loss, fatigue and weakness, nausea, and vomiting. A severe deficiency, according to the National Institutes of Health, can cause an irregular heart rhythm, muscle cramps, personality changes, sensations of numbness and tingling, and seizures.

Many of us simply aren't getting enough through our diets. However, digestive disorders such as Crohn’s disease or celiac disease can affect the ability to absorb magnesium, and people who have type 2 diabetes or take diuretics may lose more magnesium than normal through their urine. Long-term use of proton pump inhibitors for acid reflux may also lead to a magnesium deficiency.

In addition, older adults are at increased risk for magnesium deficiency because they tend to consume fewer magnesium-rich foods than younger adults, may absorb less from what they eat, and their kidneys may excrete more of it.

A few simple steps can ensure that you get your fill of magnesium. Here's how:

Understand Why Magnesium Matters

Few nutrients are more crucial than magnesium, because none of our cells could function without it. Cells need the mineral to produce ATP, a compound dubbed the body’s “energy currency,” says Fudi Wang, M.D., Ph.D., professor of nutrition at Zhejiang University in China, because it’s the bank that cells draw on to power their functions.

Among its other roles, magnesium is involved in regulating blood pressure, blood sugar, heart rate, and nerve transmission.

Consuming enough magnesium can make a positive difference in your health. In a 2016 review of 40 studies involving a total of more than 1 million people, Wang and his colleagues found that every 100 mg increase in magnesium from food reduced the risk of heart failure by 22 percent, type 2 diabetes by 19 percent, and stroke by 7 percent.

Those who consumed more magnesium were also less likely to die from any cause during the studies’ follow-up periods, which ranged from 4 to 30 years.

Focus on Food, Not Supplements

Getting your magnesium from food is best, unless your doctor instructs otherwise, Wang says.

High doses from supplements may have side effects such as diarrhea, nausea, and abdominal cramps, and may prevent some medications—such as certain antibiotics and bisphosphonates—from doing their jobs. (Supplements may be appropriate if you have a digestive disorder or diabetes.)

Though no one food has a huge amount of magnesium, it’s not hard to consume enough if you keep the best sources—dark leafy greens, legumes, nuts, and whole grains—in regular rotation, says Joan Salge Blake, Ed.D., R.D.N., clinical associate professor of nutrition at Boston University.

For instance, these foods supply at least 50 mg per serving: ½ cup cooked quinoa, 2 tablespoons pumpkin seeds, ¼ cup almonds, ¾ cup cooked chickpeas, 2 heaping cups raw spinach, and 1 ounce 70 to 85 percent dark chocolate.

'Mag' Up Your Meals

If you're having trouble figuring out how to get more magnesium into your diet, this daily menu supplies just over 420 mg.

Breakfast: Nutty Banana Oatmeal
⅓ cup rolled oats prepared with water (37 mg); ¼ cup sliced almonds (62 mg); 1 small banana, sliced (27 mg)

Lunch: Veggie Taco Bowl
¾ cup brown rice (64 mg); ⅓ cup black beans (40 mg); 1 cup sliced zucchini and yellow squash, cooked (19 mg); ¼ cup salsa (10 mg); ½ medium avocado, cubed (20 mg)

Snack: Yogurt With Raspberries
7 ounces lowfat plain Greek yogurt (22 mg), ½ cup raspberries (14 mg)

Dinner: Salmon, Spinach, and Potato
3 ounces wild salmon, broiled (31 mg); 3 cups raw spinach, sautéed with garlic and oil (71 mg); 1 small baked potato (39 mg)

Editor's Note: This article also appeared in the April 2017 issue of Consumer Reports on Health.