Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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!

截图00.png

1 Solution

Accepted Solutions
Not applicable
Author

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.

Please find the attachements

less selections.pngmore selections.png

Niranjan M.

View solution in original post

8 Replies
Not applicable
Author

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.

Not applicable
Author

hi

for get max and min value on selection, try it


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


jonathandienst
Partner - Champion III
Partner - Champion III

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

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

I love your answer. it do works

but could you explain it?

what does 'NOT' mean?

why I need to justify it?

Not applicable
Author

Hi,

Please see the link I explained it:

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

Thanks,

Niranjan M.

Not applicable
Author

it shows

Unauthorized

when I clicked the link.

Not applicable
Author

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.

Please find the attachements

less selections.pngmore selections.png

Niranjan M.

Not applicable
Author

Thanks so much for your explanation