Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

PEEK giving bad data at large numbers

Hi I am using PEEK on a table with 10 million rows , and its giving me wrong data

??

1 Solution

Accepted Solutions
cwolf
Creator III
Creator III

That means, your field is a mixed value field. It contains not only numeric values but also alphanumeric values.

And thats why you get 3 different results:

Max(DiagnosisObjectID) ==> Maximum of the numeric values

Max(Fieldvalue('DiagnosisObjectID',RecNo())) ==> it's the same as max(DiagnosisObjectID), but I think you will see here a "?" as result, because in this case QlikView don't know how to interpret it (numeric or alphanumeric).

ORDER BY DiagnosisObjectID DESC ==> Maximum of ASCII values

and with MaxString(DiagnosisObjectID) you will get another differnt result.

Normally Max(DiagnosisObjectID) should be the fastest solution of all, but in the case of mixed values QlikView has at first to filter out the numeric values, before it can determine the max value of them and thats why it takes a few of minutes.

Maybe most of your values are filled with blanks on the right or left side.

View solution in original post

11 Replies
swuehl
MVP
MVP

Could you please provide more information:

-Version (Client/ Server) and OS you are using

- exact script code you are using

Best by uploading a sample QVW that demonstrates your issue.

Anonymous
Not applicable
Author

QlikView 11.20.12904.0 SR12 64 bit

LOAD * FROM $(vPathQVD)Diagnosis.qvd (qvd);

LastDiagnosis:

LOAD DiagnosisObjectID Resident Diagnosis ORDER BY DiagnosisObjectID DESC;

Let vLastDiagnosisObjectID = Peek('DiagnosisObjectID', 0, 'LastDiagnosis')

DROP Table LastDiagnosis;

swuehl
MVP
MVP

And what do you get as value in the variable compared to what do you expect to see?

Could you also explain how you confirmed your expectation using a different approach?

Anonymous
Not applicable
Author

Instead of giving me a value, it gave  a field name of another column in that table.

I got a correct value using Max(), but it took a few minutes

swuehl
MVP
MVP

What other field name? There is only a single field in LastDiagnosis table, right?

If you want to find the maximum value of a field fast, you can also scan the symbols only:

  LOAD 

            Min(Fieldvalue('DiagnosisObjectID',RecNo())) as MinID, 

            Max(Fieldvalue('DiagnosisObjectID',RecNo())) as MaxID 

    AUTOGENERATE FieldValueCount('DiagnosisObjectID'); 

cwolf
Creator III
Creator III

The sort order of the field DiagnosisObjectID is determine by the "Load-From-Qvd" statement. The "Load-Resident-Order By" statement doesn't mean that the field will be stored in a sort order in the memory. The "order by" applies only during the load statement. To get a sort order field, you have to load it resident with a new name.

Diagnosis:

LOAD * FROM $(vPathQVD)Diagnosis.qvd (qvd);

LastDiagnosis:

First 1

LOAD

DiagnosisObjectID as LastDiagnosisObjectID

Resident Diagnosis ORDER BY DiagnosisObjectID DESC;

Let vLastDiagnosisObjectID = Peek('LastDiagnosisObjectID', 0, 'LastDiagnosis');

DROP Table LastDiagnosis;

Anonymous
Not applicable
Author

Both Stephan and Christian have interesting solutions. Thank you both.

I am in the middle of a large load, so I will check both options and let you know.

Thanks,  J

Anonymous
Not applicable
Author

Nope, both approaches did not work.

The only thing that works is:

LOAD Max(DiagnosisObjectID) AS MaxDiagnosisObjectID Resident Diagnosis;

swuehl
MVP
MVP

Could you upload some sample data?