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

Announcements
Mastering Change Data Capture: Read Now
cancel
Showing results for 
Search instead for 
Did you mean: 
buzzy996
Master II
Master II

Flag generation

Input table:

DocIdStatus
100New
100Processed
100QCError
101QCCompleted
101Processed
200New
200Processed
200QCCompleted
300New
100Processed
300Processed
400Processed
300Processed
100Processed
400QCError

------------------

Expected output table:

DocIdStatusFlag
100New2
100Processed1
100QCError2
101QCCompleted2
101Processed1
200New2
200Processed1
200QCCompleted2
300New2
100Processed2
300Processed1
400Processed1
300Processed2
100Processed2
400QCError2

Note(The above output):If First time the record(DocId with status='Processed') entered into output table then flag should be placed as 1 else 2 or 0,

even the same DocId placed seconde time in output table the flage should be 2 or 0.

any help on above

1 Solution

Accepted Solutions
MarcoWedel

Hi,

one possible solution:

LOAD *,

    If(Status='Processed', NumMin(AutoNumber(RecNo(),DocId&Status),2),2) as Flag

FROM [http://community.qlik.com/thread/130525] (html, codepage is 1252, embedded labels, table is @1);

QlikCommunity_Thread_130525_Pic1.JPG.jpg

hope this helps

regards

Marco

View solution in original post

5 Replies
MayilVahanan

Hi

Try like this

Load

If(Previous(DocID) <> DocID, 1, 2) as Flag

resident tablename

order by DocID;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
sushil353
Master II
Master II

Hi,

Try this:

LOAD *,if(AutoNumber(RollNum,DocId)>2,2,AutoNumber(RollNum,DocId)) as flag Inline

[

DocId, RollNum

100, 101

100 ,102

101 ,103

200 ,201

200 ,202

300 ,301

100 ,401

300 ,501

400 ,201

300 ,601

100 ,101

400 ,401

];

HTH

Sushil

jagan
Partner - Champion III
Partner - Champion III

Hi Shiva,

Try like this

LOAD

*,

If(Previous(DocID) <> DocID, 1, 2) as Flag;

Load

*

Resident DataSource;

Order By DocID;

Hope this helps you.

Regards,

Jagan.

DavidFoster1
Specialist
Specialist

Just use autonumber(RollNum, DocId)

MarcoWedel

Hi,

one possible solution:

LOAD *,

    If(Status='Processed', NumMin(AutoNumber(RecNo(),DocId&Status),2),2) as Flag

FROM [http://community.qlik.com/thread/130525] (html, codepage is 1252, embedded labels, table is @1);

QlikCommunity_Thread_130525_Pic1.JPG.jpg

hope this helps

regards

Marco