Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
On May 18th at 10AM EDT we will answer your QlikView questions live. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
micheledenardi
Specialist II
Specialist II

Sum of Sales of previous selected period.

Hi Guys,

i've some sales data structured as below:

2018-06-25 14_28_06-SampleData.xlsx - Excel.png

When a user select a period (or more than one), the total Sum of sales is recalculated for the selected period.

I would like to add another column with the total sum of sales for the selected period of the previous year (2017).

So, in this case, the new column will contains the sum of 01/2017,02/2017 and 03/2017 sales.

How to achieve this ?

2018-06-25 14_28_48-QlikView x64 - Copia del rivenditore - [M__SampleData.qvw_].png

1 Solution

Accepted Solutions
sunny_talwar

Try this

Sum({<Year = {"$(=Max(Year) - 1)"}, Period, Month = p(Month)>}Sales)

Where Year and Month are calculated in the script like this

Table:

LOAD Company,

    Date(Date#(Period, 'MM/YYYY'), 'MM/YYYY') as Period,

    Year(Date#(Period, 'MM/YYYY')) as Year,

    Num(Month(Date#(Period, 'MM/YYYY'))) as Month,

    IsCurrentYear,

    Sales

FROM

[SampleData.xlsx]

(ooxml, embedded labels, table is Foglio1);

View solution in original post

1 Reply
sunny_talwar

Try this

Sum({<Year = {"$(=Max(Year) - 1)"}, Period, Month = p(Month)>}Sales)

Where Year and Month are calculated in the script like this

Table:

LOAD Company,

    Date(Date#(Period, 'MM/YYYY'), 'MM/YYYY') as Period,

    Year(Date#(Period, 'MM/YYYY')) as Year,

    Num(Month(Date#(Period, 'MM/YYYY'))) as Month,

    IsCurrentYear,

    Sales

FROM

[SampleData.xlsx]

(ooxml, embedded labels, table is Foglio1);

View solution in original post