Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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 1Column 2ValueMin(Value)GapNumber
A1B13001002003
A1B210010001
A1B32001001002
A2C2505001
A2C110050502

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:

Load

     *,

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

resident Data

order by Column1, Gap

;

6 Replies
Gysbert_Wassenaar
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:

Load

     *,

     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:

Load

     *,

     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