How to Get Quarterly Trend Numbers

I think this is a pretty basic question. I am trying to create a card that shows our quarterly trend for revenue. Ideally I would do this through the formula ('Revenue' / DayofQuarter). Unfortunately, while there is a DayofWeek, DayofMonth, and DayofYear function, there is no formula for DayofQuarter. Thoughts on how I make this work? 

Comments

  • Tomo
    Tomo Contributor

    Hi @cjones

     

    An example of BEAST MODE or DataFlow SQL.

    -- DayOfQuarter
    case
    when month(`Date`) <= 3 then datediff(`Date`, concat(year(`Date`),'-01-01'))
    when month(`Date`) <= 6 then datediff(`Date`, concat(year(`Date`),'-04-01'))
    when month(`Date`) <= 9 then datediff(`Date`, concat(year(`Date`),'-07-01'))
    else datediff(`Date`, concat(year(`Date`),'-10-01'))
    end

    or

    -- DayOfQuarter
    case
    when month(`Date`) <= 3 then datediff(`Date`, concat(year(`Date`),'-01-01')) + 1
    when month(`Date`) <= 6 then datediff(`Date`, concat(year(`Date`),'-04-01')) + 1
    when month(`Date`) <= 9 then datediff(`Date`, concat(year(`Date`),'-07-01')) + 1
    else datediff(`Date`, concat(year(`Date`),'-10-01')) + 1
    end