Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help Needed

i have two columns one is ID and second is Date. My requirement is that i have to find out Row Num for each record and that i have done by RowNo() fuction but tha problem is that and the main requirement is that if the Id is changed then RowNo() again starts from 1,2,......

Help Needed Sample Data File is attached

Plz Its Urgent 

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Hello Kumar,

I think it is not a good idea to use autonumber for this purpose. Because that does not guarantee of sequencial number generation for large data set.

Thanks.

View solution in original post

11 Replies
tresesco
MVP
MVP

See the attached application.

Thanks.

Not applicable
Author

Tressco could u plz explain me what this line of code do:

If(ID=peek('ID'),Peek('Count')+1,1) as Count

Not applicable
Author

Tressco could u plz explain me what this line of code do:

If(ID=peek('ID'),Peek('Count')+1,1) as Count

Thanks In Advanced

tresesco
MVP
MVP

ID=peek('ID') - checks if the current ID is same as the previous one loaded, if so the counter is incremented(peek('count')+1). If not so, that means the ID is a new one so the counter gets initiated as 1.

Note: assumption: your data is sorted on ID field.

Hope this helps.

Thanks.

kumarnatarajan
Partner - Specialist
Partner - Specialist

Hi,

Find the attached File

tresesco
MVP
MVP

Hello Kumar,

I think it is not a good idea to use autonumber for this purpose. Because that does not guarantee of sequencial number generation for large data set.

Thanks.

Not applicable
Author

Tressco Its Not work when i fetch the dat from excel

Thanks

kumarnatarajan
Partner - Specialist
Partner - Specialist

Hi tresesco,

Ok! Thanks for advice. Please Check now . i am currected that issue using with RowNo().

See the below script. This good one:

Taple1:

LOAD *,RowNo() as TempRowNo INLINE [
    ID , Date
    A1, 5/12/13 12:00 AM
    A1, 5/13/13 12:00 AM
    A1, 5/14/13 12:00 AM
    A1, 5/15/13 12:00 AM
    B2, 5/16/13 12:00 AM
    B2, 5/17/13 12:00 AM
    C4, 5/18/13 12:00 AM
    C4, 5/19/13 12:00 AM
    C4, 5/20/13 12:00 AM
    D5, 5/21/13 12:00 AM
    E6, 5/22/13 12:00 AM

];


New_one:
NoConcatenate LOAD     ID,
        Date,
        AutoNumber(Date&TempRowNo,ID) as RowNo
Resident Taple1 order by ID, Date;

DROP Table Taple1;


tresesco
MVP
MVP

Your application data and source data do not match. Else  the output seems fine. right?