Date to quarter

Hi,

I have a date column, i want a VC for quarter means

Like if month of the date is

Feb, Mar, April = Q1
May, Jun,July = Q2
Aug, Sep, Oct =Q3
Nov, De, Jan = Q4

0 4 556
4 REPLIES 4

Aurelien
Google Developer Expert
Google Developer Expert

Hi @Anchor_Appadmin

Various possibilities

IFS(
   MONTH([TimeStamp])<=3,"Q1",
   MONTH([TimeStamp])<=6,"Q2",
   MONTH([TimeStamp])<=9,"Q3",
   true,"Q4"
)

Or (less efficient, according to article below):

SWITCH(MONTH([TimeStamp]),
   1,"Q1",
   2,"Q1",
   3,"Q1",
   4,"Q2",
   5,"Q2",
   6,"Q2",
   7,"Q3",
   8,"Q3",
   9,"Q3",
   "Q4"
)

See also:

EDIT :
@Steve in the article IFS, I think there are one extra comma in the end of the IFS and SWITCH example, Section " Weekday Name" ?

Fixed! Thanks for letting me know!

Could this be a bug?
I have tried both the sample expressions but all return โ€œQ2โ€.
my timestamp runs from May to October.

Thanks

Hi @reggieneo

It works on my side.
I suspect this is due to date format.

If all of your dates are on the same day, maybe the data wrote in your Sheets is, for example:
04/05/2021
04/06/2021
04/07/2021
04/08/2021
and so on, so that โ€œ04โ€ here is counted as the month ? If so, you may want to check your locale, here is an exhaustive list to check:

Top Labels in this Space