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

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?

View solution in original post

7 Replies
sunny_talwar

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
Creator III
Creator III
Author

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

sunny_talwar

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?

reddy-s
Master II
Master II

Hi Christoph,

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

Thanks,

Sangram.

sunny_talwar

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

igdrazil
Creator III
Creator III
Author

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
tresesco
MVP
MVP

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

Untitled.png

Though, my testing is not yet conclusive.