Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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;
Hi
this is purely hard coded,i want dynamic script.
Thanks
Thiru
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
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
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;