Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
RowNo() inserts duplicates values after I've delete rows.
This is a very simple example:
// FIRST LOAD
[test]:
load
RowNo() as MyRowNo
,value
Inline [
value
'x'
'y'
'z'
];
// REMOVE ROWS
inner keep([test])
load
MyRowNo
resident
[test]
where
MyRowNo=2
;
// CONCATENATE ROWS
[test]:
Concatenate([test])
load
RowNo() as MyRowNo
,value
Inline [
value
'a'
'b'
'c'
];
And the result is
MyRowNo | value |
2 | a |
2 | y |
3 | b |
4 | c |
Why I've duplicate values? How to resolve? This is a simple example but my code is very complex !!!
This is the best way (from https://qlikviewcookbook.com/2013/09/fastest-method-to-read-maxfield-from-a-qvd/😞
tmp:
LOAD Max(Id) as MaxId;
LOAD FieldValue('MyRowNo', recno()) as Id
AUTOGENERATE FieldValueCount('MyRowNo');
let v = Peek('MaxId');
trace $(v);
DROP Table tmp;
I also try this sintax, but it doesn't work (it's without use preloading):
tmp:
LOAD Max(FieldValue('MyRowNo', recno())) as MaxId
AUTOGENERATE FieldValueCount('MyRowNo');
let v = Peek('MaxId');
trace $(v);
DROP Table tmp;
Thanks to everyone (specially to Massimo Grossi) for their help and ideas
What do you expected to see? This:
Try RecNo() instead of RowNo()
// FIRST LOAD
[test]:
load
RowNo() as MyRowNo
,value
Inline [
value
'x'
'y'
'z'
];
// REMOVE ROWS
inner keep([test])
load
MyRowNo
resident
[test]
where
MyRowNo=2;
// CONCATENATE ROWS
[test]:
Concatenate([test])
load
RecNo() as MyRowNo
,value
Inline [
value
'a'
'b'
'c'
];
or Use Join instead of concatenate
// FIRST LOAD
[test]:
load
RowNo() as MyRowNo
,value
Inline [
value
'x'
'y'
'z'
];
// REMOVE ROWS
inner keep([test])
load
MyRowNo
resident
[test]
where
MyRowNo=2
;
// CONCATENATE ROWS
[test]:
Join([test])
load
RowNo() as MyRowNo
,value
Inline [
value
'a'
'b'
'c'
];
And the result is
MyRowNo | value |
2 | a |
2 | y |
3 | b |
4 | c |
or maybe
// FIRST LOAD
[test]:
load
RowNo() as MyRowNo
,value
Inline [
value
'x'
'y'
'z'
'w'
'j'
]
;
// REMOVE ROWS
inner keep([test])
load
MyRowNo
resident
[test]
where
MyRowNo=2 or MyRowNo=3
;
let v = NoOfRows('test');
// CONCATENATE ROWS
[test]:
Concatenate([test])
load
$(v) + RowNo() as MyRowNo
,value
Inline [
value
'a'
'b'
'c'
'y'
]
;
RecNo is not right.
I want an unique value for MyRowNo field
Join is not right.
I want an unique value for MyRowNo field and all values (I have to use Concatenate)
Somthig like this:
This solution works fine (thank's a lot!), But why RowNo() function works badly?
Modifying Massimo's script slightly for RecNo() to work
// FIRST LOAD
[test]:
load
RowNo() as MyRowNo
,value
Inline [
value
'x'
'y'
'z'
]
;
let v = NoOfRows('test');
// REMOVE ROWS
inner keep([test])
load
MyRowNo
resident
[test]
where
MyRowNo=2
;
// CONCATENATE ROWS
//[test]:
Concatenate([test])
load
$(v)+RecNo() as MyRowNo
,value
Inline [
value
'a'
'b'
'c'
]
;
With your idea
let v = NoOfRows('test');
// CONCATENATE ROWS
[test]:
Concatenate([test])
load
$(v) + RowNo() as MyRowNo
,value
Inline [
....
It's also possible use RecNo() function, adding 1:
let v = NoOfRows('test');
// CONCATENATE ROWS
[test]:
Concatenate([test])
load
$(v) + RecNo() +1 as MyRowNo
,value
Inline [
....
RecNo() function it's possible but adding 1:
$(v) + RecNo() +1 as MyRowNo