Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I use the September 2017 version.
I found an (funny?) issue with basic calculations in Qlik Sense.
Let's assume:
a=1
b=1+3
result = $(a)/$(b)
Now it's time for the question - result is equal.....
Should be 0,25, right? (1 divided by 4)
Not for QlikSense! For QlikSense the results equals 4.
I started investigation how it's possible.
It seems that Qlik instead of this:
a) calculate a variable
b) calculate b variable
c) divide: a/b
Does this:
a) do not calculate a and b
b) copy raw formulas (from variables) to the result: result = 1 / 1 +3
c) calculate it right now..
So the result is 1/1 +3 = 1+3=4
Instead of 1/4...
Is this a known issue?
Are you (Qlik team) going to solve this problem? Maybe in the November 2017 version?
This is as intended, should you want the outcome to be 0.25 then use $(=a)/$(=b)
Hi,
The Order of Operations:
"Parentheses, Exponents, Multiplication and Division, and Addition and Subtraction"
The Expression should be like = $(a)/($(b))
because you saved a and b values are in a string.
a 1
b 1+3
the calculation will be
=1/1+3
first, it will divide 1/1 then it will do addition 3.
While creating variable b you can use = symbol it will calculate the value ( =1+3 ) (4)
Nope.
It's still 4.
The Little Equals Sign doesn't work here.
1. It's not about the order of operations.
It's about the process of calculation in Qlik Sense.
2. If you have
x=2+3
and you have to multiply 2*x
what will you do?
2*(2+3) or 2*2+3
Of course the first answer is correct.
That's the logic of using variables/unknowns
The problem is that Qlik is using the second (wrong) way.
3.Using the equals sign in the definition of b variable is not a good choice.
Maybe in this example it doesn't change too much.
But - if the definition of "b" variable is more complex, the equals sign may have impact on the results of the "b" value.
4. Of course, I can put everything into brackets, but I am not looking for "workaround".
This should works correctly as in other softwares, scripting/programming languages etc.
My bad
Either change the variable definition to include the = sign
=1+3
instead of
1+3
or use
$(=$(b))
In your expression
Thanks - Finally, $(=$(b)) is working
So, instead of 3 characters a/b, I have to use 17 characters: $(=$(a))/$(=$(b))
Good that the syntax is so clear We need to add ONLY 8 x brackets, 4 x dollar signs and 2 x equals signs
Nice improvement Qlik
This is an example of incosistency.
$(a) returns 1, $(b) returns 4, $(a)/$(b) is wrong and returns 4
So you have to use $(=$(b)).
But $(=$(b)) doesn't work while you have definition with any field like b=[Field]+3
...
no comments
To be honest - this is the simplest example of using two variables.
If I have to use 17 characters to divide two variables (with 8 brackets!) what would happen if have to use 5 variables?
Please take a look at this simple calculation:
$(=$(a))/$(=$(b))*($(=$(b1))*$(=$(b2))-$(=$(c)))
Fortunately, Qlik helps us with syntax highlighting
Nope!
it doesn't help of course, there is still no good syntax highlighting
If this is intended... God help us
I disagree that this is wrong.
When you do a dollar sign expansion you are substituting text exactly as it is written. So if I have
a = 2+3
b = 2 * $(a)
I SHOULD get 2 * 2 + 3 according to the rules of dollar sign expansion. This may not be what I intended (I might want 10 as my answer, and this will give me 7), but it is the consistent way that dollar sign expansions work. If you want 2+3 to be treated as a group, then use parentheses (2+3).
I think it is correct.
1/1 + 3 = 1 + 3 = 4
I understand the operation of $() expansion.
I said it wrong beacause it's illogical and unintuitive.
If you define:
a=1
b=1+3
The results of a/b will be:
in C# 0,25
in VBA 0,25
in JS 0,25
in Maths 0,25
and so on..
in Qlik it's 4, cause it doesn't calculate varaibles before using.
The way of using variables in Qlik is opposite to standards and logic.
And finnally it's ridiculous because to write correctly this simple expression:
a/(b+c/d)
you have to use 37 characters
$(=$(a))/($(=$(b))+$(=$(c))/$(=$(d)))
and the expression is unreadable