Happy 8th birthday to the Maveryx Community! Take a walk down memory lane in our birthday blog, and don't miss out on the awesome birthday present that all Maveryx Community members get to take advantage of!
alteryx Community

# Alteryx Designer Desktop Discussions

SOLVED

## Last 4 quarters from DateTimeNow()

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
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

Alteryx

Example attached

16 - Nebula

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

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

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.

Alteryx

example of the formula for your second format

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