Investing in companies that have some haram products

Salamu alaykum, hope everyone reading this is staying safe and sane in shaa Allah.
My question goes thus : What do you do with earnings from money you made from a company that sell some haram products. For instance companies like walmart or amazon that also sell Alcohol and cigars, Or an investment platform that trades the financial markets in totality. Thank you very much for your time.