Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
Right, it seems QV parser to get confused with the Exclusion Operator '-' and negative symbol '-'.
I didn't think of that - you are possible right .
But the exclusion operator should come either before the equal sign or before the first curly braces anyway - shouldn't it?
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
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.
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.
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...