Free Trial

Alteryx Designer Desktop Discussions

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

Last 4 quarters from DateTimeNow()

LudwigB
5 - Atom

I'm having a hard time trying to  produce the last 4 quarters from DateTimeNow().  I'll have to use the 4 quarters in the column name and also as a counter.

 

I found this in our community:

 

IF ceil(DateTimeMonth(DateTimeNow())/3)!=1 then

'Q'+tostring(ceil(DateTimeMonth(DateTimeNow())/3)-1)+tostring(DateTimeYear(DateTimeNow())-2000)

else 'Q4'+tostring(DateTimeYear(DateTimeNow())-2000-1) endif

 

But it doesn't work well past the previous quarter.

 

Any help would be appreciated.

7 REPLIES 7
BrandonB
Alteryx
Alteryx

What about parsing the month out from your date and using the following?

 

IF [2]>=1 AND [2]<=3
THEN "Q1"
ELSEIF [2]>=4 AND [2]<=6
THEN "Q2"
ELSEIF [2]>=7 AND [2]<=9
THEN "Q3"
ELSEIF [2]>=10 AND [2]<=12
THEN "Q4"
ELSE Null()
ENDIF

BrandonB
Alteryx
Alteryx

Example attached

 

 

JosephSerpis
17 - Castor
17 - Castor

Hi @LudwigB I mocked a workflow that I think produces the output you describe. Let me know what you think?

 

Quarters_240919.PNG

LudwigB
5 - Atom

Brandon, yes that works.

 

I should have been more specific..

 

The business need requires the quarters to be in either of these 2 formats.  Its the year that's giving me problems.  If I am using today and going back 4 quarters (not including our current qtr), we go into year 2018.

 

2019 Q1

 or 

Q1 19

BrandonB
Alteryx
Alteryx

You should be able to use the year that has been parsed out in conjunction with the quarter field that has been created. I have attached another workflow as an example. This final formula tool can be tweaked to say right([1],2) for example if you needed to pull the last two digits from year. 

 

date parsing.png

 

BrandonB
Alteryx
Alteryx

example of the formula for your second format

 

date parsing 2.png

LudwigB
5 - Atom

I didn't see the replies below and used this one.

 

How quickly people replied, amazed me!

 

Everyone, thank you for the assistance!

 

Here is what I used, with a little tweaking.

 

 

 

 

Labels
Top Solution Authors