Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Meg00
Contributor III
Contributor III

Create a new field from two existing ones?

Hi!

I have "field 1" and "field 2" in one table, I wand to take the sum from "field 1" and divide it with the sum of "field 2" and create "field 3" from it (wich should be the result of dividing the two others).

Table looks like this 

IDField 1Field 2(non existing field 3)
01130100311398674189
011301003115403,581,5189
011301003119561,5103,5189
011301003123642,5122,5193
011301003124570130189
011301003124759131189
011301003128633,5151,5189
011301003128728152189
011301003129072158184
011301003129106154189
011301003129239,5151,5193
011301003130204,5156,5193
011301003131279,5165,5189
011301003132130170189
011301003133485,5173,5193
01130100332798,514,5193
0113010033434723189
011301003312641,565,5193
011301003323530,5124,5189

 

 

Please Help:)

 

 

 

1 Solution

Accepted Solutions
Marcos_rv
Creator II
Creator II

Try this:

LOAD

ID,

[Field 1],

[Field 2], 

[Field 1]/ [Field 2]   as [Field 3]

FROM test.qvd;

So it would be equal to the table you showed us before, now if you want to have a record by ID, with the sum of field 1, the sum of field 2 and finally field 3 (sum (field1) / sum (field2)) would be as follows:

 

LOAD *,

[Field 1]/ [Field 2]   as [Field 3] ;

LOAD

ID,

sum([Field 1]) as [Field 1],

sum([Field 2]) as [Field 2]

FROM test.qvd

group by ID;

 

Regards!!!

 

View solution in original post

5 Replies
ngosz4074
Contributor III
Contributor III

Try this:

LOAD

ID from original table,

sum(field1) / sum(field2) as field3

resident original table

group by ID;

Somasundaram
Creator III
Creator III

 

 

Tab1:

 

Load 

ID,

Field1,

Field2

from Db;

 

Load 

sum(Field1)/(Field2) as field3

resident Tab1 group by ID; 

 

Use like this


-Somasundaram

If this resolves your Query please like and accept this as an answer.
pradosh_thakur
Master II
Master II

It doesn't look like you re summing them as the out put are different for one id

Load  * , [Field 1]/[Field 2] as field3;

Load 

ID, [Field 1], [Field2]

from Table_name;

Learning never stops.
Marcos_rv
Creator II
Creator II

Try this:

LOAD

ID,

[Field 1],

[Field 2], 

[Field 1]/ [Field 2]   as [Field 3]

FROM test.qvd;

So it would be equal to the table you showed us before, now if you want to have a record by ID, with the sum of field 1, the sum of field 2 and finally field 3 (sum (field1) / sum (field2)) would be as follows:

 

LOAD *,

[Field 1]/ [Field 2]   as [Field 3] ;

LOAD

ID,

sum([Field 1]) as [Field 1],

sum([Field 2]) as [Field 2]

FROM test.qvd

group by ID;

 

Regards!!!

 

Meg00
Contributor III
Contributor III
Author

thanks to everyone for helping out!