It's weird to me to frame things as "comparing Walmart to Amazon" as if you'd only ever be considering those two options. But it's even weirder to compare to Whole Foods instead. (or at least Whole Foods as I remember it. I haven't been in years as I'd have to go out of my way these days, and Trader Joes uses that bandwidth)
Each store (or really each fulfillment method of each store) has types of items of items they're good at. That is my primary key for where I start looking.
Most items that I've found Walmart is good at, are going to be nowhere near a Whole Foods. And for food items specifically, where they do manage to overlap (premium brands), I would expect Whole Foods to be much more expensive for little gain.
In my experience, for most items that Walmart is going to be good at, Target is likely also going to be good at. Some of them will also be on Amazon at reasonable prices.