Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
LOAD
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?
try this
tAmount /( $(totalAmount) * 100) as percent
or
(tAmount /$(totalAmount) )* 100 as percent
or
div(tAmount ,$(totalAmount) )* 100 as percent
LOAD
( ( tAmount / $(totalAmount) )* 100) as percent
RESIDENT GROUP_TIMES_COMP;
Er.mohit give to you a right answer :
In your code, you multiply the total before divising.
(tAmount / $(totalAmount)) * 100
yes,
you can try
(tAmount / $(totalAmount)) * 100
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:
LOAD
tAmount/( 8324,76 * 100) as percent
RESIDENT GROUP_TIMES_COMP
Error in expression:
')' expected
LEFT JOIN GROUP_TIMES_COMP:
LOAD
(tAmount/8324,76) * 100 as percent
RESIDENT GROUP_TIMES_COMP
Error in expression:
Div takes 2 parameters
LEFT JOIN GROUP_TIMES_COMP:
LOAD
div( tAmount, 8324,76 ) * 100 as percent
RESIDENT GROUP_TIMES_COMP
<<<
If anyone knows how to divide with decimal place in divisor - feel free to post it!
Thank you for your notably fast response.