Baby diarrhea because of formula?

My girl is 7 months. She has been on the same formula for months. At 4 months she was having diarrhea for days with no other symptoms. The doctor gave the go ahead to start solid baby foods and cereal and that it might clear up the diarrhea. I did and it did clear it up. Well we have been busy moving into a new place and for days I have been just sticking to formula and now she has had diarrhea for days. Is it possible that just having the formula causes diarrhea? It smells FOUL and she has gas with it too even though I give her gas medicine. She gets Sams brand sensitive formula. The diarrhea is yellow with little chunky pieces in it. Just wondering if this is normal or a bug?