Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Moving Average Problem

I am facing some problem.

Below is my table:

  Date                    Price

6/30/2016207.210007
6/29/2016204.839996
6/28/2016201.479996
6/27/2016201.589996
6/24/2016203.630005
6/23/2016209.809998
6/22/2016208.649994
6/21/2016208.300003

Problem 1 I cannot calculate moving average 10 days in script, I only can moving average 2 days

rangeavg(Price,previous(Price)

Problme 2 Since I dont create the moving average field in the table but I want to add (Price > Moving average 10days Price) as calculated dimension

that is

=if(rangeavg(above(sum(Price),0,10))>0,1,0)

Q.png

Can anybody give me some advices?

Thanks!

11 Replies
marcus_sommer

Try this: rangeavg(above(sum(Price),rowno(),10))

- Marcus

sunny_talwar

Is it possible to share a sample with the desired output if what marcus_sommer‌ has provided doesn't work for you?

Best,

Sunny

Not applicable
Author

It is work in the expression but it doesnt work in calculated dimension

Anonymous
Not applicable
Author

Hi Garnett,

Please find attached the qvw.

Hope this helps to solve your 1st query.

marcus_sommer

If you want to use aggregations within the dimension you will need to wrap the calculation within an aggr-function:Calculated Dimensions

- Marcus

Not applicable
Author

Thanks!

Not applicable
Author

Thanks!

oknotsen
Master III
Master III

If your question is now answered, please flag the Correct Answer and possible Helpful answers.

If not, please make clear what more information on this topic you are looking for .

May you live in interesting times!
vinieme12
Champion III
Champion III

Hi@Garnett,

Having complex expression only will degrade your dashboard performance

Add the DateGroup to your load script as below

DATA:

LOAD

Date,

Price,

date(subfield(class(Date,10),' ',1),'DD-MM-YY')

&' TO '&

date(subfield(class(Date,10),' ',5),'DD-MM-YY') as DateGroup

FROM TABLENAME;

LEFT JOIN(DATA)

LOAD  DateGroup,

              Avg(Price)

RESIDENT DATA

Group BY DateGroup;

This should simplify your calculations

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.