And then I calculate the same for my rows by changing CURRENT_TIMESTAMP with ${my_date}. Then it’s easy to create a boolean field is_before_current_time_of_quarter. You just compare current_second_of_quarter with second_of_quarter built from your data
I really appreciate your proactive approach of sharing solutions.
Here are my points:
I have created second_of_day and second_of_quarter. This gives me seconds have passed in this latest quarter which starts from 1 April.
Today is 6th april. it gave me seconds of 5 days and 6th day seconds.
Here I want to say. we should use max or latest date present in my data instead of CURRENT_TIMESTAMP(). because dimension will fail if last sales happened 6 month ago. I am trying to create a quarter over quarter chart based on latest quarter as per data present compare to last quarter as per my data.
Why would you need the MAX date? Even if your sale is before the current_timestamp() it’s okay because as long as it’s between “current quarter start day” and “current timestamp” it will show.
“current quarter start day” will be 1 April 2022 if I calculate it by CURRENT_TIMESTAMP().
Lets say my last sale happened on 15 March 2022, then current or latest quarter is first quarter of this year(Jan to March) and “current quarter start day” should be 1 Jan 2022.
isn’t it?
I mean if my latest sale day is 15th March then
I should compare 1 Jan to 15th March 2022/1 Jan to 15th March 2021
If you want to compare first quarter of the year then you also need to develop ability to select the same quarters, in my calendar table I have “quarter_of_the_year” field. But since you wanted to compare UNTIL NOW, then this means current quarter start until now, I don’t understand why suddenly you want to move it into the past.
If you want to compare “last quarter that had a sale” then you would need to expose this MAX(date) in your data model and instead of calculating CURRENT, it would be the last quarter that had a sale but I’m not really sure why you would want that