Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Ran
Contributor III
Contributor III

Num Orders

hi 🙂

i have orders with many items

for example

OrderID  Item     

222              a

222             b

222            c

123          d

321           e

 

i want to make table in qlik  that will add to OrderId "-" and his num of duplicate (the first is zero so just orderId)

for example

OrderID  Item      NEWORDERID

222              a              222

222             b            222-1

222            c              222-2

123          d                 123

321           e                 321

 

tried to make Rowno() but i get  222-1235443(row)

and tried to use Peek but didnt work

their is and option to go with Peek 2 lines up and not just the Previous?OR  have any Idea to solve it? 

 

 

Thanks

1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Just Use Autonumber() 

the data doesn't need to be sorted

TEMP:

load *,OrderID&'-'&AutoNumber(OrderID&Item,OrderID) as NewOrderID inline [
OrderID,Item
222,a
222,b
222,c
123,d
321,e
];

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

3 Replies
ogster1974
Partner - Master II
Partner - Master II

Try this 

TmpOrders:
Load * Inline
[
OrderID,Item
222,a
222,b
222,c
123,d
321,e
];

NoConcatenate
Orders:
Load *,
OrderID & If(LineNum>0, '-'& LineNum,'') as NewOrderId
;
Load *,
If(OrderID<>Peek(OrderID),0,peek('LineNum')+1) as LineNum
Resident TmpOrders;

Drop table TmpOrders;

ogster1974_0-1675349765922.png

 

vinieme12
Champion III
Champion III

Just Use Autonumber() 

the data doesn't need to be sorted

TEMP:

load *,OrderID&'-'&AutoNumber(OrderID&Item,OrderID) as NewOrderID inline [
OrderID,Item
222,a
222,b
222,c
123,d
321,e
];

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Ran
Contributor III
Contributor III
Author

Thanks Guys😁