That code generates a date table to enable you to do time intelligence functions such as the week to week information you’re after. There is a simpler one if you prefer:
Basic Date Table (Power Query M function) - M Code Showcase - Enterprise DNA Forum
I highly recommend you having a date table of some description in your models to allow you to do this kind of work much easier.
Optionally you can remove the columns you don’t need after it is generated.