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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Performing simple calculations in script...

Hello,

I have a population of data imported from a server that shows up on the dimensions tabs when I make a table or chart, I would like to perform some basic math operations on this data to calculate different heuristics that are used to baseline operations, however the only way I know to do this is to write an expression or calculated dimension. Since the expression and calculated dimensions are recalculated every time a new selection is made I regard this data as dynamic.  I would like this data to be static and exist with the data that is imported from the server.  Can anyone provide me a sample of a script that I could use as an example?

For Example:

Efficiency- efficiency is calculated by dividing the run time by the total time.  I have this as an expression where one column is divided by another.  Can I write a script that would perform this calculation for all the data that is loaded from the server and have it appear as an available field/group in the dimensions tab when I try and create a new table or chart?

5 Replies
Anonymous
Not applicable
Author

You can do all kind of calculations in script unless you dont have anything based off selections i.e. listboxes etc.

Its always a best practise to do calculations in ETL.

Anonymous
Not applicable
Author

Maybe something like

Load

     [run time] ,

      [total time] ,

     [run time] / [total time]     as     [efficiency]

     etc ...................

Clever_Anjos
Employee
Employee

Could you post a sample of your script? We could suggest some calculations

Not applicable
Author

Ok, attached is a very simple example of what I am trying to do, but the efficiency isn't being calculated.  What's wrong with my syntax?

Clever_Anjos
Employee
Employee

Try this:

Data:

LOAD

RunTime,

TotalTime,

RunTime / TotalTime as Eficiency INLINE [  

      RunTime, TotalTime

      54,        100,   

      66,        110,

      74,        95,

];