Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Maveer
Contributor II
Contributor II

Division calculation in script Qlikview

Hi All,

Need your help/assistance .

I want to do this below calculation at script level, please let me know, do this is possible.

(sum(Value1))
/(1+(SUM(Value2) / SUM(Value3)))*(SUM(Value2) / SUM(Value3))
)

Value1 , Value2 , Value3  holds both decimal values and non-decimal values

I have applied this in chart expression, when ever  i choose different dimensions, numbers keep changing/dropped for same selection. Numbers should be same when ever user choose different dimensions.

 

1 Solution

Accepted Solutions
marcus_sommer

That the results change if there are different dimensions used doesn't mean mandatory that anything is wrong.

Of course an unsuitable datamodel with missing/wrong associations between the used tables/fields could cause such effect.

Beside this the available data respectively the data-quality could also have an impact, for example if there are NULL's or any invalid values within the data. This means you need to ensure that you exactly knows which data are in which scenario available because only with this you will be able to decide if the return-values are the expected/wanted results or not and if not to deduce an appropriate way to prevent unwanted results, for example to implement some kind of error-handling by using alt(Field/Expressions, 'Default-Value') or similar stuff to prevent that operands in your expression are NULL or 0 (which wouldn't return a valid result as a divisor) or any other unwanted returns.

With a bit luck you could find the cause if you put all expression-parts as separate expression in your chart. If this don't showed very obvious reasons and/or you couldn't find a simple way to adjust the output in your favour you will need to create a tablebox with all relevant fields (all used dimension- and measure-fields) to see the wrong associations between them respectively the missing/wrong values.

- Marcus

View solution in original post

2 Replies
marcus_sommer

That the results change if there are different dimensions used doesn't mean mandatory that anything is wrong.

Of course an unsuitable datamodel with missing/wrong associations between the used tables/fields could cause such effect.

Beside this the available data respectively the data-quality could also have an impact, for example if there are NULL's or any invalid values within the data. This means you need to ensure that you exactly knows which data are in which scenario available because only with this you will be able to decide if the return-values are the expected/wanted results or not and if not to deduce an appropriate way to prevent unwanted results, for example to implement some kind of error-handling by using alt(Field/Expressions, 'Default-Value') or similar stuff to prevent that operands in your expression are NULL or 0 (which wouldn't return a valid result as a divisor) or any other unwanted returns.

With a bit luck you could find the cause if you put all expression-parts as separate expression in your chart. If this don't showed very obvious reasons and/or you couldn't find a simple way to adjust the output in your favour you will need to create a tablebox with all relevant fields (all used dimension- and measure-fields) to see the wrong associations between them respectively the missing/wrong values.

- Marcus

Maveer
Contributor II
Contributor II
Author

Thanks Marcus.

The calculation which i mentioned is for particular selection. Once that selection is removed, the calculations happened with else condition. 

I did the calculations for dollar amount in Script .  Then it solved my issue.