Hello, welcome to HCM.
This situation can occur when there are certain foods that cannot be digested properly in the intestine. Be observant to know if this happens when you consume specifically some foods. Normally, people who have celian disease - intolerance to gluten tend to have symptoms of grainy or sandy stools. If you ahve consumed foods like wheat, barley, oats etc, they contain gluten and if your body is not able to tolerate that, there are high chances of having such stools. Sometimes even dairy products can lead to such grainy stools. So firstly, observe if this happened due to consumtion of these foods. If yes, then you will have to go on a gluten free
diet wherein you should avoid foods that contain gluten in them such as wheat, barley, oats etc. Avoid porridges or milk shakes made out of these ingredients. There are gluten free products in the shops which will help you buy the right products. Also, check the ingredients before you consume any foods. you can also check www.gluten.net for more details.