Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Average Function

I currently have an expression taking the sum of all weeks in the set "WeekofYear". I want to rewrite this expression to take the average of all weeks in the quarter except the most current week which is defined by the variable $(vMaxWeek).

 

 

Avg

({<[Source Type]={'RACE_REV_EST'}, [WeekOfYear] >}NAT_AMT) / $(vScaleM)

6 Replies
Jason_Michaelides
Partner - Master II
Partner - Master II

Try:

Avg

({<[Source Type]={'RACE_REV_EST'}, [WeekOfYear] ={"<>$(vMaxWeek)"} >}-{<>}  NAT_AMT) / $(vScaleM)

Hope this helps,

Jason

Not applicable
Author

Hi Jason,

Thanks for your help. I tried your expression but it's not producing a number. QlikView is having problems with the last part of the expression.

 

{<>} NAT_AMT) /

$(vScaleM)

Jason_Michaelides
Partner - Master II
Partner - Master II

Oops! Sorry - I meant to remove that...

Avg

({<[Source Type]={'RACE_REV_EST'}, [WeekOfYear] ={"<>$(vMaxWeek)"} >}  NAT_AMT) / $(vScaleM)

Not applicable
Author

Still no cigar. What if we tried to produce the average without trying to subtract out the most current week ($(vMaxWeek)) from the calculation. Would that be easier to write?

Jason_Michaelides
Partner - Master II
Partner - Master II

Can you post your app please?  Would be much easier to help then.

whiteline
Master II
Master II

Avg({<[Source Type]={"RACE_REV_EST"}, [WeekOfYear] ={"=WeekOfYear<>$(vMaxWeek)"} >}  NAT_AMT) / $(vScaleM)

And the syntax $(vMaxWeek) depends on what is stored in this variable (expression with or without =).