Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
arixooo123
Contributor

Comparing dates in set analysis

my Expression looks like this :

avg({<PurchaseDate<=2015-01-15>}Sales

as you can see I have a Date column (PurchaseDate) and a simple date 2015-01-15

in sql i would simply :

PurchaseDate <= convert(datetime,'2015-01-15',suitable Style)

thanks in advance

Tags (3)
5 Replies

Re: Comparing dates in set analysis

Try with

Avg({<PurchaseDate = {'<=2015-01-15'} >} Sales )

You can use it dynamically also

Regards

Anand

manojkulkarni
Valued Contributor II

Re: Comparing dates in set analysis


set vCompareDate=Date('2015-01-15','YYYY-MM-DD')


avg({<PurchaseDate={"<=$(vCompareDate)"}>}Sales


Make sure both the dates are in same format

greeshma_k
Contributor III

Re: Comparing dates in set analysis

Your set analysis syntax is incorrect. Please try below expression

avg({<PurchaseDate = {'<=2015-01-15'}>}Sales)

Regards,

Greeshma

Not applicable

Re: Comparing dates in set analysis

Hi,

if you want to compare a field value with a specific date or variable then use code like this

set vCompareDate=Date('2015-01-15','YYYY-MM-DD')


avg({<PurchaseDate={"<=$(vCompareDate)"}>}Sale)

----------------------------------

if you are facing problem then covert the date into number format then use (num(PurchaseDate)).

set vCompareDate=num(Date('2015-01-15','YYYY-MM-DD'))


avg({<PurchaseDate={"<=$(vCompareDate)"}>}Sales)

Regards

Vimlesh

arixooo123
Contributor

Re: Comparing dates in set analysis

the above expression does not work, i don't know why.

but, what if i try this?


avg({<Year(PurchaseDate)<2015,Month(PurchaseDate)<1>}Sales)


it is like in sql i try:

where

datepart(year,PurchaseDate)<2015 and DatePart(Month,PurchaseDate)<1

Community Browser