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: 
Not applicable

max + above functions return Null

Hi,

If I do

max(MyField - above(MyField))[/code ]I get "-" because above() return "-" for the first row. My question is to kow how to avoid this ?
Best regards,

Jérémy</body>
4 Replies
vincent_ardiet
Specialist
Specialist

Hi Jeremy,

What do you want to do exactly ?

If you want to compare the max value of a field wihtin a dimension and the previous one (that means the max value of a field with the previous dimension value), the syntax is :

=max(myField)-above(max(myField))

And if you want to avoid the NULL value, you can use a test like :

=max(myField)-if(isnull(above(max(myField))),0,above(max(myField)))

Regards,

Vincent

Not applicable
Author

Hi Vincent,

MyFiled is a field with counter values. What I want to do is to find the maximum consumption between 2 counter values.

example:

MyField

0
10
12
16
...

I want fo find the value 10 because 10 - 0 returns the max

thanks

Not applicable
Author

You could make another column which has the difference between those numbers and take the max of that column 😉

Like

MyField Diff

0 0
10 10
12 2
16 4

Max(diff) = 10

Kind Regards,

Martijn



vincent_ardiet
Specialist
Specialist

Try to compute a new column in your data script using the 'previous' function, for example :

test:

LOAD id, counter

FROM ...

join

load

id,

counter-if(isnull(previous(counter)),0,previous(counter)) as gap

resident test;



Then you can have the max(gap) in your report.

Regards,

Vincent