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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
rahulsud007
Creator
Creator

Value Conversion

Hi guys, I have Data in the following format.

PID  Qty Date

P1   5      1-Jan-2015

P1  3    2-Jan-2015.

And I need output as

PID  Flag  Date

P1     1     1-Jan-2015

P1     1     1-Jan-2015

P1     1     1-Jan-2015

P1     1     1-Jan-2015

P1     1     1-Jan-2015


P1     1     2-Jan-2015

P1     1     2-Jan-2015

P1     1     2-Jan-2015

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

If you view data thro Data model, then you will see duplicated rows. Table Box will remove the dups. Try adding RowNo()

Load *, RowNo(), 1 as Flag while Iterno() <= Qty;

LOAD PID,

     Qty,

     Date(Date#(PDate,'DD/MM/YYYY'),'DD/MM/YYYY') as PDate

FROM

Stock.xlsx

(ooxml, embedded labels, table is old)

View solution in original post

11 Replies
anbu1984
Master III
Master III

Load *,1 As Flag While IterNo() <= Qty;
Load * Inline [
PID,Qty,Date
P1,5,1-Jan-2015
P1,3,2-Jan-2015] ;

rahulsud007
Creator
Creator
Author

hi Anbu, i have tried it1.PNG this is the output i am getting for it.

anbu1984
Master III
Master III

Can you post the script you tried

rahulsud007
Creator
Creator
Author

hi this is the script.

Load *, 1 as Flag while Iterno() <= Qty;

LOAD PID,

     Qty,

     Date(Date#(PDate,'DD/MM/YYYY'),'DD/MM/YYYY') as PDate

FROM

Stock.xlsx

(ooxml, embedded labels, table is old)

;

Not applicable

Hi Rahul,

the attached should work for you, hope that helps

Joe

anbu1984
Master III
Master III

If you view data thro Data model, then you will see duplicated rows. Table Box will remove the dups. Try adding RowNo()

Load *, RowNo(), 1 as Flag while Iterno() <= Qty;

LOAD PID,

     Qty,

     Date(Date#(PDate,'DD/MM/YYYY'),'DD/MM/YYYY') as PDate

FROM

Stock.xlsx

(ooxml, embedded labels, table is old)

Anonymous
Not applicable

the Point is that anbus solution is working well

but the table on the Surface are doing what qlikview is expected to do

the data is summarized and the ouptut you showed is correct

but there is an easy Workaround if you use a straight table

use the script from Joe and add rowno() to it

Test:
LOAD * INLINE [
PID,Qty,Date
P1,5,1-Jan-2015
P1,3,2-Jan-2015
]
;
 
Let vRowCount = NoOfRows('Test');
 
For i = 0 to $(vRowCount)-1
  Test2:
Load
Peek('PID',$(i),'Test') As PID
,1
As Flag
,
Peek('Date',$(i),'Test') As Date,
rowno()

AutoGenerate Peek('Qty',$(i),'Test');
//AutoGenerate 5;
next i;
 
drop Table Test;

Then build a straight table with additional rowno as dimension

then goto tab presentation and set rowno to hide!

I attach qvw

Not applicable

I actually like the solution from abnu better, I would go with that rather than what I put, it's cleaner

Anonymous
Not applicable

no Problem, just add rowno() to the script from abnu and build a straight table

Load *,1 As Flag,
rowno() While IterNo() <= Qty;
Load * Inline [
PID,Qty,Date
P1,5,1-Jan-2015
P1,3,2-Jan-2015]
;