Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Author

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

;

View solution in original post

6 Replies
Gysbert_Wassenaar

See attached qvw.


talk is cheap, supply exceeds demand
Not applicable
Author

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
Author

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
Author

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
Author

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
Author

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