Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
Reference the table below:
I want to add the 4th Column "Last yr same qtr sales" which will show the sales of the qtr but previous year.
Any Idea what would be the code for this?
Year | Quarter | Sales | Last yr same qtr sales |
2012 | Q1 | 9665 | x |
2012 | Q2 | 2750 | x |
2012 | Q3 | 2191 | x |
2012 | Q4 | 3316 | x |
2013 | Q1 | 2656 | x |
2013 | Q2 | 2338 | x |
2013 | Q3 | 7551 | x |
2013 | Q4 | 5173 | x |
2014 | Q1 | 3360 | x |
2014 | Q2 | 6958 | x |
2014 | Q3 | 8052 | x |
2014 | Q4 | 4819 | x |
2015 | Q1 | 3633 | 3360 |
2015 | Q2 | 1890 | 6958 |
2015 | Q3 | 7665 | 8052 |
2015 | Q4 | 5055 | 4819 |
Thanks in advance.
Mike
Is this something you need from the script or front end?
Hi Sunny,
I am looking for a front end solution for this problem.
Is there any formula trick that I can use to display sales figure 2014 Q4, in the last row (of 2015 Q4)?
Here are the two options you have.
Option 1 will require a link table, so a little manipulation in the script. But I think it is little better than the option2
Option 2 will use Above function
Script for Option 1:
Table:
LOAD Year,
Quarter,
Date#(Year&Num(Right(Quarter, 1)*3, '00'), 'YYYYMM') as YearQuarter,
Sales
FROM
[https://community.qlik.com/thread/224064]
(html, codepage is 1252, embedded labels, table is @1);
LinkTable:
LOAD YearQuarter as ReportingYearQuarter,
'Q' & Ceil(Month(YearQuarter)/3) as ReportingQuarter,
Year(YearQuarter) as ReportingYear,
YearQuarter,
'CY' as Flag
Resident Table;
Concatenate (LinkTable)
LOAD YearQuarter as ReportingYearQuarter,
'Q' & Ceil(Month(YearQuarter)/3) as ReportingQuarter,
Year(YearQuarter) as ReportingYear,
AddYears(YearQuarter, -1) as YearQuarter,
'PY' as Flag
Resident Table;
Script for Option 2:
Table:
LOAD Year,
Quarter,
Sales
FROM
[https://community.qlik.com/thread/224064]
(html, codepage is 1252, embedded labels, table is @1);