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

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Writing expressions in a script instead of a chart

Hi,

I want to show sales data based on month. For that I have some expression in a stacked 100% bar chart.

count(Sales)/count(TOTAL <Month> Sales)

I was wondering if it is possible to move this expression to the script so that it is calcuated, stored and exported from the QVD and is not calculated at runtime by the QVS server. I tried pasting the script as it is but it gave an error 🙂

Reason: I am assuming this will save some processing time as I have around 100 such expressions in my QVW file.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

In spite of processing time, that will mean you need to accumulate (or get accumulations from SQL statements) which is quite contrary to the use of QlikView. You may want to set that in a variable in the script and use it later in a chart, instead of writing the same expression several times.

The only way to avoid that being calculated in runtime is doing that aggregation in the script, so yes, you can load and group by. Anyway, unless you are experiencing severe performance issues not due to data modelling or calculated dimensions, or conditionals instead of set analysis, I wouldn't recommend this kind of aggregation.

Table:LOAD ID, Sum(Amount) AS AmountFROM File.qvd (qvd)GROUP BY ID;


Of course I don't know neither your model or your indicators, and the above may be the only way to get that working.

Regards.

View solution in original post

3 Replies
Miguel_Angel_Baeyens

Hi,

In spite of processing time, that will mean you need to accumulate (or get accumulations from SQL statements) which is quite contrary to the use of QlikView. You may want to set that in a variable in the script and use it later in a chart, instead of writing the same expression several times.

The only way to avoid that being calculated in runtime is doing that aggregation in the script, so yes, you can load and group by. Anyway, unless you are experiencing severe performance issues not due to data modelling or calculated dimensions, or conditionals instead of set analysis, I wouldn't recommend this kind of aggregation.

Table:LOAD ID, Sum(Amount) AS AmountFROM File.qvd (qvd)GROUP BY ID;


Of course I don't know neither your model or your indicators, and the above may be the only way to get that working.

Regards.

Not applicable
Author

That depends, because once you put it in the script it looses the option to be re-calculated based on your current selections and it becomes a static value. If that is OK with your application's logic, then comes the syntax, which will not be identical, because you don't have the TOTAL modifier in the script version of the SUM function. You will have to do the aggregate values based on the GROUP BY clause and have a few consecutive loads in order to work this logic.

Not applicable
Author

thanks Miguel & iassen for your comments.
I realize that putting this in a qlikview script won't be of much help; it will be outdated as well.