Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Partner
Partner

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
Highlighted
Partner
Partner

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