# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Not applicable

## Make a division in loadscript

Hello,

i've a problem reading data in my table and calculating percent. When i tried this (totalAmount is 8324,76):

LEFT JOIN GROUP_TIMES_COMP:

tAmount / \$(totalAmount) * 100 as percent

RESIDENT GROUP_TIMES_COMP;

I got new colums named "tAmount / 8324" and "percent". The colum "tAmount / 8324" stores the divided values (tAmount/8324) - but i wanted to get this value multiplied by 100 in the colum "percent".

The colum "percent" stores always "7600" which seems to be the decimal place of \$(totalAmount) multiplied with 100.

I tried anything, but could not resolve this yet. Anyone knows the solution?

Tags (2)
5 Replies
Not applicable

## Re: Make a division in loadscript

try this

tAmount /( \$(totalAmount) * 100) as percent

or

(tAmount /\$(totalAmount) )* 100 as percent

or

div(tAmount ,\$(totalAmount) )* 100 as percent

Not applicable

## Re: Make a division in loadscript

( ( tAmount / \$(totalAmount) )* 100)   as percent

RESIDENT GROUP_TIMES_COMP;

Not applicable

## Re: Make a division in loadscript

Er.mohit give to you a right answer :

In your code, you multiply the total before divising.

(tAmount / \$(totalAmount)) * 100

Not applicable

## Re: Make a division in loadscript

yes,

you can try

(tAmount / \$(totalAmount)) * 100

Not applicable

## Re: Make a division in loadscript

I found the solution. The problem is decimal place of totalAmount and tAmount. This one works and is good enough for the project:

ceil(tAmount)/ceil(\$(totalAmount)) * 100 as percent

All other ways i tried gives an error or 0-values in colum percent:

>>>

Error in expression:

')' expected

LEFT JOIN GROUP_TIMES_COMP:

tAmount/( 8324,76 * 100) as percent

RESIDENT GROUP_TIMES_COMP

Error in expression:

')' expected

LEFT JOIN GROUP_TIMES_COMP:

(tAmount/8324,76) * 100 as percent

RESIDENT GROUP_TIMES_COMP

Error in expression:

Div takes 2 parameters

LEFT JOIN GROUP_TIMES_COMP: