Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi experts,
Below is the table
A B C
1 2 0/18
4 3 0.27
5 6 0.54
Requirement:
C = B/SUM(B)
eg : 2/11
Below is my load script
tableA:
Load
A,
B,
Sum(B) as totalB
from ...
group by A,B;
tableB:
Load
A,
B,
totalB,
B/totalB as C
Resident tableA;
drop table tableA;
this codes will produce this result
A B C
1 2 1
4 3 1
5 6 1
because this formula B/totalB = B/B
Any idea how?
Thank you in advance!
Hi,
do you want to sum B for each value of A or jus total of B (like 2+3+6)?
If the second option is valid than you have to create a variable.
tableA:
Load
Sum(B) as totalB
from ...;
Let vTotalB= Peek('totalB',0, 'tableA');
Drop Table tableA;
tableB:
Load
A,
B,
$(vTotalB) as totalB,
B/$(vTotalB) as C
from ...;
Hope this helps
Hi,
do you want to sum B for each value of A or jus total of B (like 2+3+6)?
If the second option is valid than you have to create a variable.
tableA:
Load
Sum(B) as totalB
from ...;
Let vTotalB= Peek('totalB',0, 'tableA');
Drop Table tableA;
tableB:
Load
A,
B,
$(vTotalB) as totalB,
B/$(vTotalB) as C
from ...;
Hope this helps
Check attached app if you want
Hi
Instead of performing the calculations at script level you can perform the same at front end.
Thanks
Hi,
superb answer!
Thanks
Hi,
There's a reason i want to do it at back end. thanks!