Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
dafnis14
Specialist
Specialist

Calculating Ratio: Script or UI?

Hi,

I need to show a monthly ratio based on records with a resolution of half an hour.

For each record, the ratio is calculated by ActualAvail/STDAvail.

In a chart I use Average for that metric, based on a period selection (Month, Year..)

I wanted to know whether I should calculate the ratio dynamically in the chart.

If so, what is the reason?

Thanks!

1 Solution

Accepted Solutions
duncanblaine
Creator
Creator

In answer to your original question:

There should be no difference arithmetically between calculating the Ratio in the UI or in script.

The only difference I can think of is the way the decimals are rendered in the UI, which is configured on the Number tab in the Object properties.

View solution in original post

5 Replies
duncanblaine
Creator
Creator

Hi Dafnis

Are you asking whether you should use the Ratio directly from your source (looks like Excel?) or calculate the Ratio in your chart?
If so, then I would say its best to calculate the Ratio in your chart using the data points you have so that it will adjust depending on your dimensions and filter selection.
If you use the Ratio from Excel, you could end up with incorrect values due the issues of aggregating ratios. Its always best to avoid pulling pre-aggregated data into Qlik, especially when you have the granular data values.

Hope this helps you.
If I've misunderstood your question, please let me know.

dafnis14
Specialist
Specialist
Author

Hi Duncan,

Thanks for your input.

The data is pulled from a database.

So the ratio is calculated in the script.

Since the metrics are to be used in a dashboard, no drill down, it is more convenient to do the aggregation in the script.

I saw a difference of around 0.04% between the 2 methods (in the script or in a chart).

Just want to make sure that it's correct "arithmetically"..

duncanblaine
Creator
Creator

Could it be that you have a number format that is affecting the decimal places, which might cause a different total when exported to Excel.

duncanblaine
Creator
Creator

In answer to your original question:

There should be no difference arithmetically between calculating the Ratio in the UI or in script.

The only difference I can think of is the way the decimals are rendered in the UI, which is configured on the Number tab in the Object properties.

dafnis14
Specialist
Specialist
Author

Thanks!