Announcements
cancel
Showing results for
Did you mean:
Partner - Creator

## How to create a variable based on another variable

Hello,

I have 2 variables vCurrentYear & vPreviousYear

vCurrentYear = right (year(today()),2)

because I only want it to get '14'

vPreviousYear =\$(vCurrentYear)-1

which will give me 13

Now, I want to create a new variable that will check a part of a field to see if its the current year or the previous year

I have a semester field which is filled like 1401, 1402, 1301, 1302

the 14 and 13 being the year.

Count( {<(Left(Semester,2))=(\$vPreviousYear)>}EMPLID)

meaning count all the EMPLID where the first two digits of the semester field are equal to the Previous year which 13.

It won't work, I think it has to do with the syntax, some help please.

1 Solution

Accepted Solutions
Not applicable

You can also keep your variables as you declared them initially and try the below:

count({<Semester={"=Left(Semester, 2) = \$(vPreviousYear)"}>} EMPLID)

6 Replies
Luminary Alumni

That's a tricky one. For now I found a small workaround modifying the vPreviousYear variable to 14*, 13* respectively.

13* in the set modifier does the same like using the left() function on the field (Which is not possible).

See attached.

Anonymous
Not applicable

I noticed a missing backet.

Count( {<(Left(Semester,2))=(\$(vPreviousYear)>}EMPLID)

I have not checked anything else though.

Partner - Creator
Author

I must've missed it after trying to mix things up,

Count( {<(Left(Semester,2))=(\$(vPreviousYear)>}EMPLID)

Eventually, written like this, I get a red line just under the bracket in bold.

Not applicable

You can also keep your variables as you declared them initially and try the below:

count({<Semester={"=Left(Semester, 2) = \$(vPreviousYear)"}>} EMPLID)

Luminary Alumni

Learned something new

Not applicable

Martin,

Here's a link for another example of how to use this kind of search strings:

http://www.naturalsynergies.com/q-tip-5-show-top-performers-common-but-not-too-trivial/

Community Browser