Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I got a simple file with a list of clients who are on double and i want to count the number of times that the client apparates (in an other field created). I know the autonumber function but it doesn' t do what i want.
I'd like a thing like that:
Client Champ_compté
Client 1 1
Client 1 2
Client 1 3
Client 2 1
Client 3 1
Client 3 2
Client4 1
How can i do this?
Thanks a lot and excuse me for my bad english
A bit simpler would be like:
Load
Client,
AutoNumber(RecNo(), Client) as Champ_compté
Hi,
I'm afraid it is not as simple as is looks like.
My suggestion is to loop over the distinct clients and generate your "Champ_compte" field. Concatenate all the Records and join them to the data.
NOTE: RecNo() is the number in the Source and RowNo() is the number in the resulting table.
Hope this helps
Regards Tobias
Hi,
Use this expression in script
if(Client=peek(Client),NumSum(1,peek(i)) ,1) as i
Regards,
Amay
A bit simpler would be like:
Load
Client,
AutoNumber(RecNo(), Client) as Champ_compté
Something like this? A simple peek() call will add the required counter to an already sorted table. Make sure that your Client occurrences are sorted before applying this code:
RawData:
LOAD *, if (peek('Client') = Client, RangeSum(peek('Champ_compté'),1), 1) AS Champ_compté INLINE [
Client
Client 1
Client 1
Client 1
Client 2
Client 3
Client 3
Client4
];
Result:
Hi sab ben,
NOTE: To make sure Amay Patils solution is working correctly you have to load the Clients order by Client first. Because it is not able to deal with the same client occuring later on again.
Regards Tobias
yess Thank you Tobias !!!!
Yes thanks a lot peter but i didn't know the peek function!!
Thanks