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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
gabriele
Contributor
Contributor

Compare date with a variable

Hello.

I have a problem for counting records lower of a data of last year.

I have try:

count({$<[Mydata.autoCalendar.Date]={"<Data1ago"}>} [Sales])

but don't work.

where Data1ago is a variable so defined           =Date(AddYears(Today(), -1))

Could anyone help me? Thank you

Labels (1)
1 Solution

Accepted Solutions
JordyWegman
Partner - Master
Partner - Master

Hi Gabriele,

The problem is that your variable isn't executed, try this:

 

count({$<[Mydata.autoCalendar.Date]={"<$(Data1ago)"}>} [Sales])

 

Besides this, you can expect some problems with your date format when it's not correct. The best thing to do would be to floor all your dates.

// Add this in your script

Floor([Mydata.autoCalendar.Date]) as [Mydata.autoCalendar.Date]

// and floor your variable

Date1ago = Floor(Date(AddYears(Today(), -1)))

 

Jordy

Climber 

Work smarter, not harder

View solution in original post

1 Reply
JordyWegman
Partner - Master
Partner - Master

Hi Gabriele,

The problem is that your variable isn't executed, try this:

 

count({$<[Mydata.autoCalendar.Date]={"<$(Data1ago)"}>} [Sales])

 

Besides this, you can expect some problems with your date format when it's not correct. The best thing to do would be to floor all your dates.

// Add this in your script

Floor([Mydata.autoCalendar.Date]) as [Mydata.autoCalendar.Date]

// and floor your variable

Date1ago = Floor(Date(AddYears(Today(), -1)))

 

Jordy

Climber 

Work smarter, not harder