Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I trying to create unique number for repeting vaules in script level
Eq
Value | Trying to create Key |
1 | 1 |
1 | 2 |
1 | 3 |
1 | 4 |
2 | 1 |
2 | 3 |
2 | 4 |
3 | 1 |
3 | 2 |
Can any one help
regards
Mahesh
Hi Mahesh,
this works:
Data:
LOAD * INLINE [
Value
1
1
1
1
2
2
2
3
3
];
Result:
NOCONCATENATE LOAD Value, if(IsNull(Previous(Value)) or Value>Previous(Value), 1, Peek(Key)+1) as Key
Resident Data;
- Ralf
Hi Mahesh,
this works:
Data:
LOAD * INLINE [
Value
1
1
1
1
2
2
2
3
3
];
Result:
NOCONCATENATE LOAD Value, if(IsNull(Previous(Value)) or Value>Previous(Value), 1, Peek(Key)+1) as Key
Resident Data;
- Ralf
Try:
Data:
LOAD *, if(Value=previous(Value), peek(Key)+1,1) as Key INLINE [
Value
1
1
1
1
2
2
2
3
3
];
Another option:
Data:
LOAD *, autonumber(recno(),Value) as Key INLINE [
Value
1
1
1
1
2
2
2
3
3
];
Try this
Data:
LOAD * INLINE [
Value
1
1
1
1
2
2
2
3
3
];
NewData:
LOAD Value,
if(Previous(Value)<>Value,1,RangeSum(1,Peek(Key))) as Key
Resident Data
Order by Value;
DROP Table Data;
output like this
Value | Key |
1 | 1 |
1 | 2 |
1 | 3 |
1 | 4 |
2 | 1 |
2 | 2 |
2 | 3 |
3 | 1 |
3 | 2 |
See the attached file
Interesting solution! But, this could be expensive for QV to handle a large amount of counters..
- Ralf