Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
swarup_malli
Specialist
Specialist

Pick top 2 values in list box?

Hi ,

  I have a list box which has values from 2008 to 2013.

  I want the listbox to display current year and previous year ( ie 2012 and 2013)

  I know this can be achieved using the expression inside the list box.

My requirement is I don't want to hardcode year in order to pick top 2 values.

  I tried using the following expression inside the listbox

if (year=max(year) or year=max(year-1))

But the thing is when I click on 2012 in the list box ,it show 2011.

  Is there a way this can be achieved without hardcoding year values ?

Thanks

SM

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Try with this

=If(Match(Year, Max({1} Year), Max({1}Year)-1)), Year)

Edit:

=If(Match(Year, $(=Max({1} Year)), $(=Max({1} Year)-1)), Year)

Hope it helps

Celambarasan

View solution in original post

7 Replies
Gysbert_Wassenaar

Something like this: =aggr(if(rank(Year)<=2,Year),Year)

If you want you could also replace the 2 with a variable so you can change the top x by changing the value of the variable.


talk is cheap, supply exceeds demand
swarup_malli
Specialist
Specialist
Author

Thank you !!! Gysbert

swarup_malli
Specialist
Specialist
Author

Hey Gysbert,

   When i make a selection in list box, say I choose 2013, then all other values disappear, how can I not make them disappear ?

I don't want to hard code any year

CELAMBARASAN
Partner - Champion
Partner - Champion

Try with this

=If(Match(Year, Max({1} Year), Max({1}Year)-1)), Year)

Edit:

=If(Match(Year, $(=Max({1} Year)), $(=Max({1} Year)-1)), Year)

Hope it helps

Celambarasan

Anonymous
Not applicable

In the expresssion

=If(Match(Year, $(=Max({1} Year)), $(=Max({1} Year)-1)), Year)

wt does  {1} stand for ?

Balraj

swarup_malli
Specialist
Specialist
Author

I guess {1}  represents the full set of all the records in the application

Not applicable

Excellentooo..!! it solved dropdown filter issue. Thanks boss.