Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating new field

Hi all,

I have 3 fields:

ValueQuantityAverage Value
10004250
500010500
300031000
200020100
10005200
300030100
500022500
.........
.........

now I want to get a 4th field that looks like the following:

Avg * Qty

250

250
250
250
500
500
...
..(10 times 500)
..
1000
1000
1000
...

Does anyone have an idea how to achieve this?

Thank you very much in advance!

Best regards

7 Replies
its_anandrjs

Hi,

Try to use Iterno() function here that may help you a lot.

Regards

Anand

maxgro
MVP
MVP

a:

LOAD Value,

     Quantity,

     [Average Value]

FROM

[http://community.qlik.com/thread/158239]

(html, codepage is 1252, embedded labels, table is @1)

where left(trim(Value),1)<>'.' ;

b:

load

  [Average Value],

  IterNo()

Resident

  a

While 0+IterNo() <= Quantity;



Not applicable
Author

Thank you for your quick responses!!

Is it possible to store these values in an own field?

I have now:

Avg     IterNo

x          1

x          2

y          1   

y          2

y          3

and so on, which is exactly what I was looking for, but I need the new Avg values in a new field.

maxgro
MVP
MVP

maybe this?

b:

load

  [Average Value] as NameOfNewField,

  IterNo()

Resident

  a

While 0+IterNo() <= Quantity;

pokassov
Specialist
Specialist

b:

load

  [Average Value] as [New avg],

  IterNo()

Resident

  a

While 0+IterNo() <= Quantity;

MK_QSL
MVP
MVP

Use below Script..

Test:

Load

  Value,

  Quantity,

  Quantity as TempQty,

  Value/Quantity as [Average Value]

Inline

[

  Value, Quantity

  1000, 4

  5000, 10

  3000, 3

  2000, 20

  1000, 5

  3000, 30

  5000, 2

];

NoConcatenate

Load

  Value,

  Quantity as TotalQty,

  (Quantity - IterNo() + 1) as [Individual Line Qty],

  [Average Value] as [Average Line Value]

Resident Test

While (Quantity - IterNo() + 1) > 0;

Drop Table Test;

Not applicable
Author

Unfortunately, this does not work.. The Values of the new field don't make any sense and the iterno() function does not work properly anymore. It counts from 1 to sum(all qty) for every value.