Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
helen_pip
Creator III
Creator III

Previous Quarter Number using Mapping Load (Not working- December)

Hello

I was wondering if someone could kindly help me

I have a QVW and using a MAPPING LOAD I load in a spreadsheet so I can obtain the Current Quarter according to the month number

The spreadsheet data looks like this:

MonthQuarter
14
24
34
41
51
61
72
82
92
103
113
123

By using apply Map I am able to retrieve the current quarter

applymap('Quarters_Map', num(month(Today())), null()) AS Current_Quarter

I also have a 2nd field where I can retrieve the Quarter for the previous month.   In 2013 this worked perfectly, however now we have moved into 2014, the following line of code now returns either a 0 or nothing

applymap('Quarter_Name', MonthName(Today()),-1), null() AS Current_Quarter_Month_End

I am assuming that my mapping load is not working and cannot count back from 1 back to 12, so can anyone kindly help me retrieve the previous quarter number, from Today's date

Kind Regards

Helen 

2 Replies
maxgro
MVP
MVP

Hi

if I understand your question you can try this to calculate quarter and quarter of previous month

Table:

load

     d,

     'Q' & ceil(month(d)/3) as QuarterCurrent,

     'Q' & ceil(month(addmonths(monthstart(d),-1)) / 3) as QuarterPreviousMonth          // -1 or -3 for your case

;

LOAD

  floor(Today() + rand()*1000) as d

AutoGenerate

  100;

Not applicable

Hi Helen,

I Hope help this script,

LOAD *, 'Q' & Ceil(Month(Today())/3) AS Quarter1,'Q' & ceil(Month(addmonths(Today(),-1)) / 3) as  Pre_Quarter1 Inline

[Quarter,Pre_Quarter

Quarter1,Pre_Quarter1];

Regards,

Raja.