# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for
Did you mean:
Contributor

## Count by values

Hi community,

I need to calculate a counting in a simple table chart using the values of one the columns, which values are not unique.

I want a result that look like the following example

 XX Counting A 1 A 2 A 3 B 1 B 2 C 1 D 1 D 2

I tried to use rowno(TOTAL) but that is not the solution for my needs.

I will really appreciate any hint to solve that

Ivan

1 Solution

Accepted Solutions
MVP

Hi Ivan, a chart will group values based on the dimensións used, if there is only one dimension, there will be only one value per row, so I think you will need at least a second dimensión wich tells why to paint 3 different 'A'.

In script you can add this counter using a sorted load and Peek() or Previous():

If(Peek('XX')=XX, RangeSum(Peek('Counting'), 1), 1) as Counting

Resident TableName

Order By XX, OtherSortingFields;

3 Replies
MVP

Hi Ivan, a chart will group values based on the dimensións used, if there is only one dimension, there will be only one value per row, so I think you will need at least a second dimensión wich tells why to paint 3 different 'A'.

In script you can add this counter using a sorted load and Peek() or Previous():

If(Peek('XX')=XX, RangeSum(Peek('Counting'), 1), 1) as Counting

Resident TableName

Order By XX, OtherSortingFields;

MVP

Although not as efficient as Peek()/Previous() pointed out by rubenmarin‌, but AutoNumber is another possible solution for the script

AutoNumber(RowNo(), XX) as Counting

Reisdent ....

Order by XX;

Champion III

Another expression using Ruben's Peek().

Check this.

Table1:

XX

A

A

A

B

B

C

D

D

];

LEFT JOIN(Table1)

Table2:

LOAD *, IF(XX = Previous(XX), Peek(Counting)+1, 1) AS Counting

Resident Table1

Order By XX;

Community Browser