Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Andy Uttley, Alteryx ACE, makes music with Alteryx | Math + Music
SOLVED

Date to Quarter and Year

Highlighted
7 - Meteor

I have a date column 1/1/2017 that I need to convert to quarter and year 1Q 2017. What is the best way to do that? 

Thanks in advance.

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Probably not the best way to go about this, but I don't think there are any 'quarter' capabilities with alteryx's default date time tools (though James Dunkerlys add on may have this level of detail in).

The following formula should suffice (presuming your date is in the format MM/DD/YYYY)

 

 


IF

tonumber(left([datefield],findstring([datefield],"/"))) < 4 then "1Q "

elseif

tonumber(left([datefield],findstring([datefield],"/"))) < 7 then "2Q "

elseif

tonumber(left([datefield],findstring([datefield],"/"))) < 10 then "3Q "

else "4Q "

endif

+ Right([datefield],4)

 

and if your date format is dd/mm/yyyy then the following should do...

 


IF

tonumber(substring([datefield],findstring([datefield],"/")+1,findstring(right([datefield],length([datefield])-(findstring([datefield],"/")+1)),"/"))) < 4 then "1Q "

elseif

tonumber(substring([datefield],findstring([datefield],"/")+1,findstring(right([datefield],length([datefield])-(findstring([datefield],"/")+1)),"/"))) < 7 then "2Q "

elseif

tonumber(substring([datefield],findstring([datefield],"/")+1,findstring(right([datefield],length([datefield])-(findstring([datefield],"/")+1)),"/"))) < 10 then "3Q "

else "4Q "

endif

+ Right([datefield],4)

See the attached workflow to see how I have implemented these.

Regards,
Ben

Highlighted
7 - Meteor

Thanks Ben,

Worked like a charm. Big help. 

Highlighted
6 - Meteoroid

What would this formula look like if my date is in this format yyyy-mm-dd?

Highlighted
5 - Atom

Hi, 

this should work if [date] is a Date-Type:

 

"Q" + ToString(
CEIL(DateTimeMonth([Date])/3)
)

+ " " + ToString(DateTimeYear([Date]))

Highlighted
5 - Atom

Thanks so much for this string/formula - worked perfectly!

Labels