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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
marcel_olmo
Partner Ambassador
Partner Ambassador

How can I count the number of appearances of a record in the loading script?

Hello guys,

I have a problem like this :

load * inline [

id description

10 hello1

10 hello1

10 hello1

10 hello1

20 hello1

];

And I want to calculate how many times has the id number repeated. Somethink like :

ID counter
10 4

20 1

Anybody knows how can I do that?

Many thanks in advance.

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Hi Marcel,

Try this code :

TestTable:

LOAD * INLINE [

ID, Description

10, hello1

10, hello1

10, hello1

10, hello1

20, hello2

];

Load *,

count(ID)as Counter

resident TestTable group by ID,Description;

....Regards,

tresesco



View solution in original post

11 Replies
Not applicable

Hi,

You can create a straight table to display the result...

use expression

Count (Description)

Check the attached example....

Thanks and Regards!!!

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Thank you nilupaboralessa for your answer.

I've seen your script. I know it's easy to do it when the document is loaded, but I need to do it when the document is not loaded yet.

I need to know how many times each id appears in the script, to do a Loop for another table.

Many thanks in advance

sunil2288
Creator III
Creator III

HI Marcel,

Without loading the document how can you use the data..

After loading the Document only you can work upon it..

Regards

Sunil

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Well, what I really need to do is an scheme accounts loading document, and I need to do two nested for bucles to check the ranks of the accounts document. The second bucle is for how many times the number of an account appears in the table.

Are you telling me this is impossible? Even loading resident tables?

Thanks a million.

Regards

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Well, what I really need to do is an scheme accounts loading document, and I need to do two nested for bucles to check the ranks of the accounts document. The second bucle is for how many times the number of an account appears in the table.

Are you telling me this is impossible? Even loading resident tables?

Thanks a million.

Regards

Not applicable

TRy the count() function

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Thanks Steve for your reply,

it was the first thing I did, count( id ) and even count(distinct id), and it didn't work.

Thanks anyway!

tresesco
MVP
MVP

Hi Marcel,

Try this code :

TestTable:

LOAD * INLINE [

ID, Description

10, hello1

10, hello1

10, hello1

10, hello1

20, hello2

];

Load *,

count(ID)as Counter

resident TestTable group by ID,Description;

....Regards,

tresesco



sunil2288
Creator III
Creator III

HI Marcel,

You can do this using resident load but you need to write the funstion like FieldValueCount with if condition.

It is present in Function Category (inter record) in the edit Script..

Try for other functions also ..

Hope it will help you

Regards,

Sunil