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

Expression-fed variable not returning the anticipated value

Hi all,

I'm relatively new to QlikView and have learned a great deal so far from all of your super advice by reading discussions on a variety of topics.  This time, however, I couldn't find an answer to my question so I thought it best to ask you directly.

I am tasked with creating a line chart where the results of different list box picks are filtered down in the chart results.  No problem - that's how a chart works in QV.  When a user makes multiple selections from the CallWeekEnding list box (which contains a week ending date for each week), the chart should create a new line.  This will allow users to compare one week's results to another week. The chart dimension will be a daily (Monday - Sunday) breakdown.  Users will be able to select/compare up to 4 weeks.

This caused me to think about set analysis.  But, how do I capture and isolate individual selections from the CallWeekEnding list box?  And how do I take those selections and graph them separately?  Here is my thought process.  Isolate individual selections by creating expression-fed variables.  Use the values of those variables in separate expressions in the chart so that each expression is graphed separately.  It seemed like a great plan, but it didn't work.

I created 5 variables:  vSelectedCallWeekEnding1 through vSelectedCallWeek4, and  vSelectedCallWeekEnding.   For the latter, the definition is GetFieldSelection(CallWeekEnding).  The definition I created for vSelectedCallWeekEnding1 is this:  If(GetSelectedCount(CallWeekEnding)>=1,SubField($(vSelectedCallWeekEnding),',',1),'').  Basically, if there is at least one item selected from Call Week Ending, then using the SubField function, parse the value saved in vSelectedCallWeekEnding using comma as a delimiter, and return the first delimited value.   vSelectedCallWeekEnding2 through vSelectedCallWeek4 use the same definition, except I change out the "1" in the definition for 2, 3 or 4, depending on the variable I am trying to define.

So, I thought if I took vSelectedCallWeekEnding1 and put it in a chart expression, I would get a graphed line.  Wrong.  Didn't happen.  So, I created three text boxes to test my values.

Text box 1:  =$(vSelectedCallWeekEnding1)      The value returned was 7/13/2014, which is exactly what I have selected in the list box.  So far so good.

Text box 2:  =If($(vSelectedCallWeekEnding1)='7/13/2014','Equal','Not Equal').   This was to test whether or not the value saved in the variable matched what I thought it should be -- '7/13/2014'.   If it matches, the expression should return 'Equal'.   And that's just what it did.  Yay.

Text box 3:   Compare the set analysis expression I attempted in my chart to the same expression with the hard coded value 7/13/2014.    =Count({$<CallWeekEnding={'$(vSelectedCallWeekEnding1)'}>session_key) & Chr(10) & Count({$<CallWeekEnding={'7/13/2014'}>}session_key)         The results were surprising to me.  The text box returned 0  100000.

So, despite the fact that in text box 2, I performed a test to compare the value of vSelectedCallWeekEnding1 to '7/13/2014' and the test came back as the values were equal, the expressions in text box 3 that performed set analysis upon the variable and the hard-coded value evaluated differently.

Can someone please explain to me why they evaluated differently, and if there is a better approach to graphing up to 4 different week-ending picks as separate expressions in the same chart(perhaps alternate state?) than what I have conceptualized here?

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

I think you need an = sign - try this:

     Count({$<CallWeekEnding={'$(=vSelectedCallWeekEnding1)'}>session_key)


HTH

Jonathan

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

try using the complete set into variable ...

ex:

defile variable

Set vMaxDate = {'$(=max(Date))'}

=sum({<Date=$(vMaxDate)>}Sales)

Anonymous
Not applicable
Author

I gave it a try but had no luck.  Thanks!