Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I created a variable called vTotal which is a formula and it contains one of the expressions I pulled out of the chart. I just
wanted to save this value and use this variable when I need it. So this is what I did but I can't get the value to display in a text object.
1. Settings -> Variable Overview -> Add
I named it "vTotal" and pasted the expression into the Definition box.
2. Placed a text object and set the Text to "=$(vTotal)".
3. Saved the QVW file
4. Reloaded it.
The text object shows "--". Looks like two dashes and I'm not able to see the result of the expression.
Am I doing this correctly or am I missing something?
Thanks
I deleted this variable. I now placed this code in the load script as:
SET vTotal =
'
= AGGR(SUM({1 <%Col1 = {"$(=Col2)"}, %Col3 = {"$(=Col4)"} >}[Amount1]) ,%Col1,%KEY_FY)
+
AGGR(SUM({1 <%Col1 = {"$(=Col2)"}, %Col3 = {"$(=Col4)"} >}[Amount2]) ,%Col1,%KEY_FY)
';
I'm getting the two dashes in my text box.
It seems like Qlikview doesn't like AGGR(). When I removed the AGGR() function, the text box showed a value. Can some validate my claim??
In a text box, the above variable will only show a value if the Aggregated table has all rows with the same information. If now, Then I believe you need to add a Sum(Aggr()) or Count(Aggr()) or some kind of function so that it can consolidate all the values and spit a single number in a text box object.
Dear Sidneylu,
Please keep in mind, when you are creating variable then you must select Variable after that write your expression in your Variable Overview => Definition Box.
When you are calling your variable name then use Dollar Sign Expenssion ($).
Kind regards,
Ishfaque Ahmed
All the data is there. The chart which contains that expression is being displayed properly. So I just took that expression and made it a formula so I can use it when I need it. One thing I'm not sure is when the formula gets evaluated? Is it possible is a timing issue in my case? Again I have different tabs in my QVW file. So does the formula get evaluated after the tab is clicked and all the selections have been made or as sson as the tab is clicked, it runs the formula first?
The problem is that the $ expansion is performed before the rest of the expression is evaluated. This means the $ expansion also applies to Set statements, which you might not expect. The $ expansions do not work so they expand to null.
You need to defer the $ expansions. One way that I prefer is:
Set vTotal = = AGGR(SUM({1 <%Col1 = {"#(=Col2)"}, %Col3 = {"#(=Col4)"} >}[Amount1]) ,%Col1,%KEY_FY)
+
AGGR(SUM({1 <%Col1 = {"#(=Col2)"}, %Col3 = {"#(=Col4)"} >}[Amount2]) ,%Col1,%KEY_FY);
Let vTotal = Replace(vTotal, '#(', '$(');
I'm not able to get this to work. First I placed the SET & LET you provided in my edit script and before any LOAD commands. When I hit CTRL R, I got an error on the LET command. Then I move the LET to the end and after all the
LOAD statements completed. I was able to refresh without any issue. However the text box which is set to
=$(vTotal) still show blank. Am I not doing this correctly?
Change the Let to:
Let vTotal = Replace(vTotal, '#', '$');
(Even here, QV was attempting a $ expansion!)
OK. I revised the LET and placed both the SET and LET statements before any LOAD statement. I was able to refresh it. However I get this error now. Any idea what this could be? Thanks.
Just wanted to clarify my earlier reply. I was playing around with the SET statement yesterday and had removed the AGGR(). So when I ran this morning, I got the above "garbage after expression" error. When I put the AGG() back, the text box is still blank (or showing two tiny dashes).