Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

genrating more records in qlikview script

Hi

I have scenario,

I have to generate 3 more records in  qlikview using script

Example

Date Location       Value

2014   Delhi           3000

2015   Hyderabad  5000

2016     Bangalore   7000

want to generate  delhi records

2014    delhi1      3000/3=1000

2014     delhi2      1000

2014    delhi3         1000

then i need to merge both

Date Location       Value

2014   Delhi           3000

2015   Hyderabad  5000

2016     Bangalore   7000

2014    delhi1      1000

2014     delhi2      1000

2014    delhi3         1000

Can anybody do the needful

Thiru

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Data:

LOAD * INLINE [

Date, Location,      Value

2014,  Delhi,          3000

2015,  Hyderabad,  5000

2016,    Bangalore,  7000

];

Concatenate (Data)

LOAD

  Date,

  Location & IterNo() as Location,

  Value/3 as Value

Resident Data

While IterNo() <=3 AND Location = 'Delhi'

;

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

View solution in original post

5 Replies
Anonymous
Not applicable
Author

use this Code

Tmp:

load * Inline [

Date, Location, Value

2014, delhi1, 1000

2014, delhi2, 1000

2014, delhi3, 1000

];

concatenate (yourtable)

load *

resident Tmp;

drop table Tmp;

Not applicable
Author

Hi

this is purely hard coded,i want dynamic script.

Thanks

Thiru

Anonymous
Not applicable
Author

try this

Tmp:

load * Inline [

Date, Location

2014, delhi1

2014, delhi2

2014, delhi3

];

left join (Tmp)

load

'2014' as Date,

Value/3

resident yourtable

where Location='Delhi';

concatenate (yourtable)

load *

resident Tmp;

drop table Tmp;

still not dynamic enough? then explain

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Data:

LOAD * INLINE [

Date, Location,      Value

2014,  Delhi,          3000

2015,  Hyderabad,  5000

2016,    Bangalore,  7000

];

Concatenate (Data)

LOAD

  Date,

  Location & IterNo() as Location,

  Value/3 as Value

Resident Data

While IterNo() <=3 AND Location = 'Delhi'

;

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

Not applicable
Author

Hi,

You can try this,

Here for Location division, you want to provide value in variable vTogenerate.

for e.g : you need 4 division, in backend you want to give Let vTogenerate=4;

File:

LOAD * INLINE [

    Date, Location, Value

    2014, Delhi, 3000

    2014, Hyderabad, 5000

    2014, Bangalore, 7000

];

Output:

Load *,Date&'-'&Location as Key

Resident File;

Drop table File;

Let vTogenerate = 3;

FOR i=1 to $(vTogenerate)

A:

Load Key,

Date as New_Date,

Sum(Value)/$(vTogenerate) as New_Value,

Location&$(i) as New_Location

Resident Output

where Location='Delhi'  // if you need for all location you can comment this line

Group by Location,Date,Key;

Next i

Concatenate (Output)

Load

New_Date as Date,

New_Location as Location,

New_Value as Value,

'1' as Flag

Resident A;

Drop table A;