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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Peony
Creator III
Creator III

Row Orderin Load script

Hi all

Please, help me to find a solution how to calculate row order for Action_ID field. Data should be aggregated by Customer and Date as it shows in sample table. What function to use in load script to get a result?

Customer_IDDateAction_IDAction_Order
a125-Mar-2020449e1
a125-Mar-20204054rt2
a18-Jul-2020ac51-4bde1
a18-Jan-202169600bc73fe41
a213-Jul-2020a5fa6717f7bf1
a214-Jul-20204828-a2c11
a214-Jul-2020401r2
a214-Jul-2020c7673
a210-Oct-20204a43-85de1
a210-Oct-202045ae-ad42
a21-Feb-20212985-44f91
Labels (1)
1 Solution

Accepted Solutions
joseph_morales
Creator III
Creator III

Hi @Peony 

You can try this:

AutoNumber(Action_ID,Customer_ID&'-'&Date)

 

In my example I use the DATE # to transform the Date field because I am loading the data from an inline, but in your case it would not be necessary.

LOAD 
Customer_ID,
DATE#([Date],'DD-MM-YYYY')		as Date,
Action_ID,
AutoNumber(Action_ID,Customer_ID&'-'&DATE#([Date],'DD-MM-YYYY'))  as Action_Order;
LOAD * Inline [
Customer_ID, Date, Action_ID
a1,	25-Mar-2020, 449e
a1,	25-Mar-2020, 4054rt
a1,	8-Jul-2020, ac51-4bde
a1,	8-Jan-2021, 69600bc73fe4
a2,	13-Jul-2020, a5fa6717f7bf
a2,	14-Jul-2020, 4828-a2c1
a2,	14-Jul-2020, 401r
a2,	14-Jul-2020, c767
a2,	10-Oct-2020, 4a43-85de
a2,	10-Oct-2020, 45ae-ad4
a2,	1-Feb-2021, 2985-44f9
];

Result

joseph_morales_0-1612990451380.png

 

 

Best Regards,
Joseph Morales

View solution in original post

2 Replies
joseph_morales
Creator III
Creator III

Hi @Peony 

You can try this:

AutoNumber(Action_ID,Customer_ID&'-'&Date)

 

In my example I use the DATE # to transform the Date field because I am loading the data from an inline, but in your case it would not be necessary.

LOAD 
Customer_ID,
DATE#([Date],'DD-MM-YYYY')		as Date,
Action_ID,
AutoNumber(Action_ID,Customer_ID&'-'&DATE#([Date],'DD-MM-YYYY'))  as Action_Order;
LOAD * Inline [
Customer_ID, Date, Action_ID
a1,	25-Mar-2020, 449e
a1,	25-Mar-2020, 4054rt
a1,	8-Jul-2020, ac51-4bde
a1,	8-Jan-2021, 69600bc73fe4
a2,	13-Jul-2020, a5fa6717f7bf
a2,	14-Jul-2020, 4828-a2c1
a2,	14-Jul-2020, 401r
a2,	14-Jul-2020, c767
a2,	10-Oct-2020, 4a43-85de
a2,	10-Oct-2020, 45ae-ad4
a2,	1-Feb-2021, 2985-44f9
];

Result

joseph_morales_0-1612990451380.png

 

 

Best Regards,
Joseph Morales
Peony
Creator III
Creator III
Author

@joseph_morales  thank you much for your solution. It works perfectly for me.