Build monthly retention matrix

I found an article on how to solve that easily please can you help me with this ?