Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Date format to Quarter

ntelyuk
5 - Atom

I have a question is there an easy way or an add-on to Alteryx that will automatically convert the data format 2017-01-01 into 2017 Q1 ? How can I figure this out without a bunch of weird codes? Thanks.

 

 

20 REPLIES 20
mbarone
16 - Nebula
16 - Nebula

No add ons or instant tools for this, that I know of.

 

A couple options, the one I like best (and use myself) is a macro.  Code it once, and you never have to again.

 

Personally, I'd make it one not-terribly-long if/then statement.  I prefer boolean if/then, but you can use traditional if/then/else or if/then/elseif if you like.  

 

Here's my formula:

 

Left([incomingdate],4)+' Q'+

IIF(Substring([incomingdate],5,2) IN ('01','02','03'),'1',
IIF(Substring([incomingdate],5,2) IN ('04','05','06'),'2',
IIF(Substring([incomingdate],5,2) IN ('07','08','09'),'3',
IIF(Substring([incomingdate],5,2) IN ('10','11','12'),'4',
Null()

))))

 

 

You make that into a macro and it just becomes another tool.

 

Kanderson
10 - Fireball

I would install the tools created by James Dunkerley. I use them so often they may as well be a native part of the Alteryx platform.

 

 

https://community.alteryx.com/t5/Data-Preparation-Blending/Formula-AddIn-to-make-working-with-Dates-...

 

 

 

 

 

 

KaneG
Alteryx Alumni (Retired)

The following formula should also get you there:

 

DateTimeFormat([Date],'%Y Q') + ToString(Ceil(ToNumber(DateTimeFormat([Date],'%m'))/3))

 

However, that may fall into your category of 'a bunch of weird codes'

ntelyuk
5 - Atom

Thanks

ntelyuk
5 - Atom

This one works great, thanks!

mocalvo
7 - Meteor

Thank you!  This just worked perfectly for me.

It would normally fall under my category of 'a bunch of weird codes' as well but I was willing to take the chance.

pvara
8 - Asteroid

Love the formula however how would you shift the quarters if our Fiscal Year started Oct 2017?

KaneG
Alteryx Alumni (Retired)

@pvara,

 

You could write a more complicated IF Then formula, however the easiest way would be to shift your Date by 3 months, so wherever [Date] is referenced, replace with DateTimeAdd([Date],3,'months')

anilmekna
6 - Meteoroid

Thank you it works well

Labels