# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Not applicable

## Numbering of rows in ascending order of values

I am stuck with this problem.

Each row has a value, Min(Value), Gap and Number.

Value is an input.

Min(Value) = Minimum among all values for each data point in Column 1.

For eg. For A1 in the table below, there are 3 values. Minimum of these 3 values is needed in Min(Value)

Gap = Value - Min(Value) for each row.

Each data point is to be numbered in ascending order of Value.

 Column 1 Column 2 Value Min(Value) Gap Number A1 B1 300 100 200 3 A1 B2 100 100 0 1 A1 B3 200 100 100 2 A2 C2 50 50 0 1 A2 C1 100 50 50 2

I could do till Gap. I used Group by to get Min(TDC) but I am unable to assign "Number"

Any help is really appreciated.

Regards

Raghav

1 Solution

Accepted Solutions
Not applicable

## Re: Numbering of rows in ascending order of values

I thought that you want to create the number column.

Change the name anyway you like:

tData:

*,

if (peek('Column1')<>Column1, 1, peek('NewName')+1) as NewName

resident Data

order by Column1, Gap

;

6 Replies
Not applicable

## Re: Numbering of rows in ascending order of values

See attached qvw.

talk is cheap, supply exceeds demand
Not applicable

## Re: Numbering of rows in ascending order of values

Thanks for the immediate input Gysbert.

Is there anyway to do this through Script?

I need to use "Number" column as a list box.

Regards

Raghav

Not applicable

## Re: Numbering of rows in ascending order of values

Let's say that your are in table callde Data.

Then you could use :

Noconcatenate

tData:

*,

if (peek('Column1')<>Column1, 1, peek('Number')+1) as Number

resident Data

order by Column1, Gap

;

Not applicable

## Re: Numbering of rows in ascending order of values

Thanks nannyogg

But if 'Number' is already defined once in a previous table, would it be possible to add use the same name again?

I tried this and got an error "Field names must be unique within the table"

Any way around for this problem?

Regards

Raghav

Not applicable

## Re: Numbering of rows in ascending order of values

I thought that you want to create the number column.

Change the name anyway you like:

tData:

*,

if (peek('Column1')<>Column1, 1, peek('NewName')+1) as NewName

resident Data

order by Column1, Gap

;

Not applicable

## Re: Numbering of rows in ascending order of values

Thanks Nannyogg.

That was the error I had been doing.

I was defining 'Number' earlier in the table.

Also I tried using Previous(Number). I am not very clear on the difference between Peek and Previous functions.

Regards

Raghav

Community Browser