Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

FleetingImage
New Contributor

Apply a filter to a variable

I created this variable in the load script:

set vSaleCur = sum( {<#(vFlag) = {'1'}, Actual_only = {'Yes'}, Comparative=, Year = {#(=#(vMaxYear))}>} SALES);

let vSaleCur = replace('$(vSaleCur)', '#', chr(36));

Now I'm using it in a chart as en expression, like this:

=$(vSalesCur)

Now I need to apply a new filter when using the variable as an expression in the chart so it disregards the filter by month, something like this:

=sum( {<Month=>} $(vSalesCur))

I do not want to add the filter when creating the variable and I do not want to create a new variable with the new filter included because this is one example that I need to do with a lot of other variables

So...

NOT THIS:

set vSaleCur = sum( {<#(vFlag) = {'1'}, Actual_only = {'Yes'}, Comparative=, Month=, Year = {#(=#(vMaxYear))}>} SALES);

NOT THIS EITHER:

set vSaleCurNew = sum( {<#(vFlag) = {'1'}, Actual_only = {'Yes'}, Comparative=, Month=, Year = {#(=#(vMaxYear))}>} SALES);  

Any thoughts?

 

2 Replies
Highlighted
JGMDataAnalysis
Contributor II

Re: Apply a filter to a variable

Something like this?

Script

set vSaleCur = sum({<#(vFlag) = {'1'}, Actual_only = {'Yes'}, Comparative =, Year = {#(=#(vMaxYear))} #(=replace('#1', '|', ','))>} SALES);

let vSaleCur = replace('$(vSaleCur)', '#', chr(36));

Front End

Adding the set modifier that ignores the selections made on the Month field...

$(vSaleCur(| Month =))

Without adding additional set modifiers...

$(vSaleCur( ))

Highlighted
FleetingImage
New Contributor

Re: Apply a filter to a variable

Hi JGMD,

I want to avoid changing the script.  I want to know if there is a way to change the variable in the front end keeping the back-end untouched.  So the question is if there is a way to apply further filtering in a variable already calculated?

If I'm using $(vSalesCur), how can I wrap it around a new expression that allows me to add a new filter to it?

Something like =(<$(vSalesCur), Month=>)