Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 | Q1 | P1 | Q1 |
201402 | Q1 | P1 | Q1 |
201403 | Q1 | P1 | Q1 |
201404 | Q2 | P2 | Q1,Q2 |
201405 | Q2 | P2 | Q1,Q2 |
201406 | Q2 | P2 | Q1,Q2 |
201407 | Q3 | P3 | Q1,Q2,Q3 |
201408 | Q3 | P3 | Q1,Q2,Q3 |
201409 | Q3 | P3 | Q1,Q2,Q3 |
201410 | Q4 | P4 | Q1,Q2,Q3,Q4 |
201411 | Q4 | P4 | Q1,Q2,Q3,Q4 |
201412 | Q4 | P4 | Q1,Q2,Q3,Q4 |
201501 | Q1 | P1 | Q1 |
Please help
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.
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'))))
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