Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selecting previous quarters

Hi All,

I have dataset which loads Year-Month. I have created month , year, quarter columns.


Requirement is to create new column which selects current quarter and previous quarters based on month start.

Year-Month  Quarter       newColumn      newColumn should select
201401             Q1P1Q1
201402            Q1P1Q1
201403    Q1P1Q1
201404        Q2P2Q1,Q2
201405        Q2P2Q1,Q2
201406Q2P2Q1,Q2
201407         Q3P3Q1,Q2,Q3
201408        Q3P3Q1,Q2,Q3
201409Q3P3Q1,Q2,Q3
201410            Q4P4Q1,Q2,Q3,Q4
201411        Q4P4Q1,Q2,Q3,Q4
201412  Q4P4Q1,Q2,Q3,Q4
201501Q1P1Q1

Please help

3 Replies
nagaiank
Specialist III
Specialist III

Instead of creating a new column, you may create a new table as follows:

Load * Inline [

NewColumn, Quarter

P1,Q1

P2,Q1

P2,Q2

P3,Q1

P3,Q2

P3,Q3

P4,Q1

P4,Q2

P4,Q3

P4,Q4

];

If you select P4, Q,Q2,Q3 and Q4 will be selected.

its_anandrjs

You can write for new newColumn should select

If(match(NewColumn,'P1'),'Q1',

If(match(NewColumn,'P1','P2'),'Q1','Q2',

If(match(NewColumn,'P1','P2','P3'),'Q1','Q2','Q3',

If(match(NewColumn,'P1','P2','P3','P4'),'Q1','Q2','Q3','Q4'))))

javier_florian
Creator III
Creator III

Hi Sravanthi,

You can work with a format -> YYYY-QQ, in order to improve your selections. For example, if you want select previous quarter in the same year, you can "write" *2013.

-JFlorian