8 Replies Latest reply: Jan 25, 2013 1:20 AM by Qianyu Zhuo

# Get the max and min value of my selection

Dear all, could you help me to get the max value of my selection

Eg. Now my selection of period is 201011, 201012, 201101

I wanna to get the max and min of it: max should be 201101, min should be 201011

I tried RangeMax

it works when I try RangeMax(2011,2012,2013), the result is '2013'

but when I tries RangeMax(GetFieldSelections(period)), the result is '-'

I wonder why the expression failed

Help!

Thanks so much!

• ###### Re: Get the max and min value of my selection

Hi,

use this expression for getting max of current sections.

=if(Left(GetFieldSelections(Year),3) = 'NOT',

max({<Year-={\$(=SubField(GetFieldSelections(Year),'NOT ',2))}>} Year),

max(Year))

note:

if you have large year values then you need to use the GetFieldSelections(Year,maxvalues) fuction

where maxvalues is the number more than the half of the field values count.

hope it helps you.

Niranjan M.

• ###### Re: Get the max and min value of my selection

but could you explain it?

what does 'NOT' mean?

why I need to justify it?

• ###### Re: Get the max and min value of my selection

Hi,

http://community.qlik.com/message/303451#303451

Thanks,

Niranjan M.

• ###### Re: Get the max and min value of my selection

it shows

# Unauthorized

• ###### Re: Get the max and min value of my selection

when you select more values of select box  and remaining values not selected are very less then getfieldselections() will return the text NOT followed by not selected values:

for example I have field called year ranges from 2005- 2014

If I select less values say 2005-2008, GetFieldSelections(Year)  will return all the years with , delimited.

when I select 2005-2012, GetFieldSelections(Year) will return Not 2013,2014

So I used not in that solution.

Niranjan M.

• ###### Re: Get the max and min value of my selection

Thanks so much for your explanation

• ###### Re: Get the max and min value of my selection

hi

for get max and min value on selection, try it

sum({<year = {"\$(=max(year))"}>}sales)

• ###### Re: Get the max and min value of my selection

Hi

Not sure if I have understood your question properly, but just use Max(period) and Min(period). These respect your selections so they will contain the latest and earliest period from your selection.

If you want to use it in an expression, the previous post is almost right:

Sum({period = {"\$(=Max(period))"} sales)

Regards

Jonathan