Hi guys,
Looked in other posts here but couldn't find the exact answer. I'm creating a table card that would show YTD vs Year prior (Bar charts are not an option since comparing many different categories. The best I could find to show Year prior is
SUM(CASE WHEN YEAR(DocDate
)= YEAR(DATE_SUB(CURDATE(), INTERVAL 1 YEAR)) AND month(DocDate
) <= month(CURDATE()) THEN DocTotal_Contribution
ELSE 0 END)
The issue with that is that is is summarizing all data from 2023 including all month of April. I want to compare data from time Jan 01 2023 till today (April 18 of 2023). Vs Year to Date (Jan 01 2024 vs today)
To calculate YTD I use the following formula and is working just fine.
SUM(CASE WHEN YEAR(DocDate
) = YEAR(CURDATE()) THEN DocTotal_Contribution
ELSE 0 END)
How can I add the extra layer to count also the current day in the year prior?
Thanks