Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate Above values

Dear Qlikview Users,

I have one tough situation in developing a qlikview dashboard, that is how to calculate sales of New York in the past months? Please find the sample data below:

CityMonthSalesAvg Above Sales
NewYork2013/7/110001000
NewYork2013/8/112001100
NewYork2013/9/115001233.333333
NewYork2013/10/120001425
NewYork2013/11/130001740
NewYork2013/12/118001750
NewYork2014/1/112001671.428571

The last column, always calculate the average sales amount from 2013-07-1 to current month.

I really have no idea, can you please help on this? Many thanks.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Use below Script...

Sales:

Load

  City,

  Date(Date#(Month,'YYYY/M/D')) as Month,

  Sales

Inline

[

  City, Month, Sales

  NewYork, 2013/7/1, 1000

  NewYork, 2013/8/1, 1200

  NewYork, 2013/9/1, 1500

  NewYork, 2013/10/1, 2000

  NewYork, 2013/11/1, 3000

  NewYork, 2013/12/1, 1800

  NewYork, 2014/1/1, 1200

];

NoConcatenate

Final:

Load

  RowNo() as NO,

  City,

  Month,

  Sales,

  RangeSum(Peek(TotalSales),Sales) as TotalSales,

  RangeSum(Peek(TotalSales),Sales)/RowNo() as AvgSales 

Resident Sales

Order By City, Month;

Drop Table Sales;

View solution in original post

2 Replies
MK_QSL
MVP
MVP

Use below Script...

Sales:

Load

  City,

  Date(Date#(Month,'YYYY/M/D')) as Month,

  Sales

Inline

[

  City, Month, Sales

  NewYork, 2013/7/1, 1000

  NewYork, 2013/8/1, 1200

  NewYork, 2013/9/1, 1500

  NewYork, 2013/10/1, 2000

  NewYork, 2013/11/1, 3000

  NewYork, 2013/12/1, 1800

  NewYork, 2014/1/1, 1200

];

NoConcatenate

Final:

Load

  RowNo() as NO,

  City,

  Month,

  Sales,

  RangeSum(Peek(TotalSales),Sales) as TotalSales,

  RangeSum(Peek(TotalSales),Sales)/RowNo() as AvgSales 

Resident Sales

Order By City, Month;

Drop Table Sales;

Not applicable
Author

Thank you very much, it works.