Good Morning! I need to create a metric to compare sales for this month (until today) with sales for the same month last year, but in equal periods.
I made a metric that compares the months, but I don't buy in equal periods being:
❌ So he compares the following dates:06/01/2021 until 06/23/2021 (today) x 06/01/2020 until 06/30/2020.
✔️ I need him to compare the same dates being:06/01/2021 until 06/23/2021 (today) x 06/01/2020 until 06/23/2020 (today).
Thank you so much for your help!
Best answer by Michael Ullock
thanks for reaching out.
To achieve this, your metric would look like this:
For this Month/Year to todays date:
SELECT <SUM-Metric> WHERE Month/Year (Data) = THIS AND Day of Month (Data) BETWEEN D1 AND THIS
For the previous Month/Year to the same day of the month for the previous year:
SELECT <SUM-Metric> WHERE Month/Year (Data) = THIS-12 AND Day of Month (Data) BETWEEN D1 AND THIS
The trick here is to use the "Day of Month" Attribute in your metric and then also select the "D1" value. In the above example, I have also added "<SUM-Metric>", there you would just insert your SUM metric. After this you should be all set.