Comparing monthly income in a certain year to the same month income in previous year

Hello! I have a dataset which contains departments, dates (several years, daily) and income per that department & date. I'm trying to build a table that has departments in the rows and monthly income as values. The columns are a certain year and the previous year. Tried with Sum and Lag. How do I do that?