Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

jaarroyl
New Contributor III

How to Count in Ascending way

Hello World!

Please your help to get this results in Count

Name - Count

Jaime - 1

Jaime - 2

Jaime - 3

I need to count the times that appears the each name starting from 1. I want to use this variable to only considering all the names that appears max 2 times in the database.

 

Thanks

Labels (2)
4 Replies

Re: How to Count in Ascending way

Hi, you can create a list box with names repeated max 2 times with this expression:
=Aggr(If(Count(Name)<=2, Name), Name)

Or in text box as comma separated list with this expression:
=Concat(DISTINCT {<Name={"=Count(Name)<=2"}>} Name, ', ')
jaarroyl
New Contributor III

Re: How to Count in Ascending way

Hi.

Thanks, but we want to count the total number of names only counting 2 times max per name. 

I mean,

Name 

Jaime

Jaime

Jaime

Ignacio

Ignacio

Ignacio

Ignacio

Carlos

Carlos

 

What I'm tring to do is counting in ascending all the features getting:

Name / Count

Jaime, 1

Jaime, 2

Jaime, 3

Ignacio, 1

Ignacio, 2

Ignacio, 3

Ignacio, 4

Carlos,1

Carlos,2

 

The variable Count in a list box should show:

Count

1

2

3

4

I want to generate a table that count (Count({<Count <= {2}>} Name)

So the results should be: 6

 

Best,

Re: How to Count in Ascending way

It depends on how you use your data, one way is generating that new field while loading using Peek and a sorted load:

LOAD Name,
If(Peek('Name')=Name, Peek('Count')+1, 1) as Count
Resident tablename
order by Name;

And the expression:
Count({<Count = {"<=2"}>} Name)

Highlighted
jaarroyl
New Contributor III

Re: How to Count in Ascending way

Not working.

If you could do in the script please?.

I attached the Qlikview

We need to do it by rut_contratante