Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Announcing the newest addition to the Qlik Community, Qlik Gallery! Learn More
Meg00
New 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
Contributor II

Re: Create a new field from two existing ones?

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!!!

 

5 Replies
ngosz4074
New Contributor III

Re: Create a new field from two existing ones?

Try this:

LOAD

ID from original table,

sum(field1) / sum(field2) as field3

resident original table

group by ID;

Somasundaram
Contributor III

Re: Create a new field from two existing ones?

 

 

Tab1:

 

Load 

ID,

Field1,

Field2

from Db;

 

Load 

sum(Field1)/(Field2) as field3

resident Tab1 group by ID; 

 

Use like this


-Somasundaram
pradosh_thakur
Honored Contributor II

Re: Create a new field from two existing ones?

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
Contributor II

Re: Create a new field from two existing ones?

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
New Contributor III

Re: Create a new field from two existing ones?

thanks to everyone for helping out!