Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
LINKEDIN LIVE: Democratizing data to enhance customer-centricity. JULY 29TH REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
bashar_f
Partner
Partner

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.

now what I put into the variable was this

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)

View solution in original post

6 Replies
simondachstr
Luminary Alumni
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.

bill_markham

I noticed a missing backet.

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

I have not checked anything else though.

bashar_f
Partner
Partner
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)

View solution in original post

simondachstr
Luminary Alumni
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/