• This should give you a start (although you might need a Calendar table to join to so you can PARTITION wherever you want.)
    https://blog.bertwagner.com/heres-a-quick-way-to-generate-a-running-total-in-sql-server-f5654d310030