Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

igdrazil
Contributor III

Getting Max Value of a Field

Hi Community,

I searched for this a lot now and I also found a few threads that all show me the same method (like this one):

Find out max numerical value in a QlikView script | Qlik Community

When using the described method, I get a value but it is not the highest in my dataset.

For more explanation:

I have a field called ExpNr which contains only numerical values (at the moment from 1 to 9) so I expect the value 9 for my script:

TempMaxExpNr:

Load Max(ExpNr) as MaxExpNr resident Experiment_Info;

Let vExpMax = FieldValue('MaxExpNr', 1);

But instead of 9, I get the value 3.

I hope someone can help me with my problem

Regards

Chris

1 Solution

Accepted Solutions
MVP
MVP

Re: Getting Max Value of a Field

I don't think it would make a difference, but can you try this:

LET vExpMax = Peek('MaxExpNr');

Also if possible, would you be able to share a sample?

7 Replies
MVP
MVP

Re: Getting Max Value of a Field

I don't think it would make a difference, but can you try this:

LET vExpMax = Peek('MaxExpNr');

Also if possible, would you be able to share a sample?

igdrazil
Contributor III

Re: Getting Max Value of a Field

Actually, it makes a difference. I tried Peek() the second you mentioned it, and it works ...

Sometimes I don't understand this program at all.

Thank you Sunny!

Regards

Chris

MVP
MVP

Re: Getting Max Value of a Field

For this sample, I get the same values

Table:

LOAD * Inline [

Field

1

2

3

4

5

6

7

8

9

];

Max:

LOAD Max(Field) as MaxField

Resident Table;

LET vMax1 = FieldValue('MaxField', 1);

LET vMax2 = Peek('MaxField');

TRACE FieldValue $(vMax1);

TRACE Peek $(vMax2);

Do you happen to have MaxExpNr created elsewhere in the script as well?

reddys310
Honored Contributor II

Re: Getting Max Value of a Field

Hi Christoph,

As sunny mentioned, Peek() function should help solve your issue after the max() aggregation.

Thanks,

Sangram.

MVP
MVP

Re: Getting Max Value of a Field

But Sangram why would FieldValue() won't work? Is it a bug in QlikSense?

igdrazil
Contributor III

Re: Getting Max Value of a Field

Hi Sunny,

no, I do not use it somewhere else.

I can not provide sample data due to security issues.

But your example is probably exactly the same data setup (the difference would be that the values in ExpNr happen to appear multiple times. The data looks somewhat like this

ExpNrcntTimestamp
11201.01.2016 00:00:00
11101.01.2016 01:00:00
2301.01.2016 00:00:00
2123501.01.2016 01:00:00
MVP
MVP

Re: Getting Max Value of a Field

The 'Note' in help talks about exactly the same.

Untitled.png

Though, my testing is not yet conclusive.