Hi, I would like to know How can I calculate the LY (Last Year) in a database of 4 years, I want to compare LY and CY (Current Year). I have a database with the monthkey, Sales for everyday$$, product attributes, Thank you for your help.
Without knowing your data structure, I'd likely:
Hi @KatyKab .
That is a great question!
Assuming that the year is in every column of your 4-year database, and if not, you can extract the year from the sales for everyday date and create a column with the name transaction_date - make this an integer
Next, create a new column that extracts the year form today (this to automate the process) and called it current_year (make this an integer), and also calculate last_year = current_year - 1
Then you can add a filter to extract current_year and last_year.
Finally, transpose the data. You should end up with something like:
monthkey | everyday$$_last_year | product_attributes_last_year | everyday$$_current_year | product_attributes_current_year
This way you can perform calculations at the row level.
Hope this helps 😊