Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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
Contributor III

Re. :max + above functions return Null

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

Re. :max + above functions return Null

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

max + above functions return Null

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

Like

MyField Diff

0 0
10 10
12 2
16 4

Max(diff) = 10

Kind Regards,

Martijn



vincent_ardiet
Contributor III

Re. :Re: max + above functions return Null

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

Community Browser