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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
petter
Partner - Champion III
Partner - Champion III

Why doesn't Set Expressions with modifier accept negative numbers as constants in an element list?

Hello community,

I am used to writing set expressions like these:

Sum( { <rDate={1,2,3,4,5}> }  Sales )

I would also like to use something like this:

Sum( { <rDate={-1,-2,-3,-4-,-5}> } Sales )

But that doesn't work very well. From all my tests I can only conclude that listing numbers will only work with positive numbers. As soon as I involve negative numbers the numbers has to be quoted like they were strings... which they obviously are not. Is this just a quirk that I have to accept in QlikView or am I missing something here?

This will work:

Sum( { <rDate={'-1','-2','-3','-4','-5'}> } Sales )

It seems a bit like a weird thing not to accept a minus in front of a number and accept it as negative. I can certainly live with it but it seems very clumsy.

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Perhaps, single quotes don't essentially cause a string transformation, but find for exact match. Or, may be after converting it to string qv handles the values intelligently; for numeric and strings accordingly. And it is seen that qv is good enough to identify data types and operate, like :

Left('12AA',2)+10 ... works fine without having to convert the string to number.

View solution in original post

7 Replies
tresesco
MVP
MVP

Right, it seems QV parser to get confused with the Exclusion Operator '-' and negative symbol '-'.

petter
Partner - Champion III
Partner - Champion III
Author

I didn't think of that - you are possible right .

petter
Partner - Champion III
Partner - Champion III
Author

But the exclusion operator should come either before the equal sign or before the first curly braces anyway - shouldn't it?

marcus_sommer

For me it looked like a bug then with '-1' ... it queries a string - meant this a negative number and a string with a negative number will return the same result? Or won't the string-case match?

An alternatively which isn't so confusing could be to use a search-function within the set analysis:

Sum( { <rDate={"$(=match(rDate, -1,-2,-3,-4,-5))"}> } Sales )

- Marcus

tresesco
MVP
MVP

Perhaps, single quotes don't essentially cause a string transformation, but find for exact match. Or, may be after converting it to string qv handles the values intelligently; for numeric and strings accordingly. And it is seen that qv is good enough to identify data types and operate, like :

Left('12AA',2)+10 ... works fine without having to convert the string to number.

jonathandienst
Partner - Champion III
Partner - Champion III

I've never had a problem that the set analysis does not correctly handle the (quoted) negative numbers , although I agree that it's odd that you have to quote them.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

As a corollary, it is not necessary to quote strings if they contain no spaces or reserved characters:

     Sum{<AField = {SomeValue}>} Amount)   -works perfectly (and the syntax checker does not complain)

     Sum{<AField = {Some Value}>} Amount)   - does not work


Which makes it even more odd that negative numbers should be quoted)

--Last checked on SR9...

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein