Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcement: Certain actions are currently causing a Page Not Found error. This is a known issue and we are working with the platform vendor to investigate and resolve it.
New Contributor III

avg between dates


I've read lots of posts but still can't crack this

I'm using Qlik Sense and would like a 4 week average on sales units

I have a variable for Current Week

=Max([Start Wk])  is set as  vCurrentStWk

My date field is [Start Wk]

I noticed it has a timestamp e.g. 25/06/2018 00:00:00 so I have tried the following but still had no joy

Avg({<date([Start Wk],'DD/MM/YYYY')={'>=$(vCurrentStWk)-28'}}>} [Sold Qty])

I would love some help


Tags (2)
3 Replies
Contributor III

Re: avg between dates


I don't think it is necessary to change date format by Start Wk. It seems as a little problem with syntax (definitelly you have extra } in expression)

try it like following

Avg({<[Start Wk]={">=$(=$(vCurrentStWk)-28)"}>} [Sold Qty])

Honored Contributor II

Re: avg between dates

Try by removing time stamp from the date and then use it in the expression?

Since your expression just has date format not the timestamp format.. thats why it work?

New Contributor III

Re: avg between dates

Thanks David but Still not working ;0(

I have tried loading date without the timestamp into a new field called StartWKNTS and setting that as the Variable to avoid the formatting issue

I noticed

=$(vCurrentStartWK) shows as 15/07/2018

but  =$(vCurrentStartWK)-28 shows as 43268

num(Date#(StartWkNTS,'DD/MM/YYYY')) shows as 43289

I tried variations on the following but still no Joy

Avg({<[StartWKNTS]={">=$(=$(vCurrentStWk)-28)"}>} [Sold Qty])

Avg({<num(Date#(StartWkNTS,'DD/MM/YYYY'))={">=$(=$(vCurrentStWk)-28)"}>} [Sold Qty])

Avg({<num(Date#(StartWkNTS,'DD/MM/YYYY'))={">=$(vCurrentStartWK)-28"}>} [Sold Qty])