Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Select last 4 values in a field

I'd like to set an option where  if i click a button , I need to select last 4 values in a field

Example : in this scenario , the field Campaign Starting Quarters has values : Q1-13 , Q2-13, Q3-13,Q4-13,Q1-14,Q2-14,Q3-14,Q414

I'd like to select the last 4 values which 'll be Q1-14,Q2-14,Q3-14,Q4-14

Is there a max function or any other function or code that allows me to do this?

Thanks a lot in advance

1 Solution

Accepted Solutions
maxgro
MVP
MVP

try with the action select in field

='(' & concat(aggr(if(rank(right(field,2) & left(field,2) )<=4,field),field), '|') & ')'

RESULT

1.png

TEST SCRIPT

load * inline [

field

Q1-12

Q2-12

Q3-12

Q2-13

Q3-13

Q4-13

Q1-14

Q4-12

Q1-13

Q2-14

Q3-14

];

View solution in original post

2 Replies
anbu1984
Master III
Master III

Check this

maxgro
MVP
MVP

try with the action select in field

='(' & concat(aggr(if(rank(right(field,2) & left(field,2) )<=4,field),field), '|') & ')'

RESULT

1.png

TEST SCRIPT

load * inline [

field

Q1-12

Q2-12

Q3-12

Q2-13

Q3-13

Q4-13

Q1-14

Q4-12

Q1-13

Q2-14

Q3-14

];