Create Bar Chart with Current Month Vs Previous Month?

Options

Hello, I have a data set of invoices that I want to compare in a bar graph where one bar is March and the other bar is Feb. I think I can do this with a beast mode but I think my syntax is off.

Case when Title LIKE '%OTT%' Then 'OTT'
AND MONTH(Date) = CURRENT_DATE(MONTH(Date)) THEN 'Current Month'
Case when Title LIKE '%OTT%' Then 'OTT'
AND MONTH(Date) = CURRENT_DATE(MONTH(Date))-1 THEN 'Previous Month'
ELSE ''

Can someone help me with this beastmode?

Comments

  • MichelleH
    Options

    @deona720 You only need to include the word CASE once within a case statement, but every CASE must be concluded with the word END. I also recommend using the LAST_DAY function (which returns the last day of the month) over the MONTH function since it also accounts for the year. Your formula should look like this:

    Case 
      when Title LIKE '%OTT%' AND LAST_DAY(Date) = LAST_DAY(CURRENT_DATE()) 
        THEN 'Current Month'
    when Title LIKE '%OTT%' AND LAST_DAY(Date) = LAST_DAY(DATE_SUB(CURRENT_DATE(), interval 1 month)) THEN 'Previous Month'
    ELSE '' END