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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
SerSwagster
Creator
Creator

Subtraction of a variable

Hi everyone. I created this variable:

last_year = year(today())-1

In the following script, I need to do a count reffered to two years ago:

count({1<[Years]={"($(last_year) - 1)"},[Team]=P([Team])>}distinct [Player])

There is a syntax mistake when calculating last year - 1. How can I fix it?

1 Solution

Accepted Solutions
marcus_sommer

There is a typo. Change it to:

count({1<[Years]={"$(=$(last_year) - 1)"},[Team]=P([Team])>}distinct [Player])

- Marcus

View solution in original post

3 Replies
marcus_sommer

You could try:

let last_year = year(today())-1;

count({1<[Years]={"$=($(last_year) - 1)"},[Team]=P([Team])>}distinct [Player])

- Marcus

SerSwagster
Creator
Creator
Author

Hi Marcus,

neither with {"$=($(last_year) - 1)"}, a result is given back. It's very strange, because putting a value to years value, there is a result. There is something wrong with "$" character.

 

marcus_sommer

There is a typo. Change it to:

count({1<[Years]={"$(=$(last_year) - 1)"},[Team]=P([Team])>}distinct [Player])

- Marcus