Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Cloud Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Cloud.

Sales Comparison with LY and CY in Cloud

KatyKab
6 - Meteoroid

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.

2 REPLIES 2
alexnajm
17 - Castor
17 - Castor

Without knowing your data structure, I'd likely:

  • use a Formula to label LY vs CY vs non-CY-or-LY
  • Filter to only CY and LY
  • Summarize, grouping on your label column and summing sales
javier_rios
Alteryx
Alteryx

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 😊