Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

JustinDallas
Valued Contributor II

LET variable, evaluate with braces

Hello Folks,

I'm trying to set a simple variable in my script.  Right now, it looks like so:

LET vHasLastShift = COUNT({<IsLastShift={'*'}-{''}>}[Stop Number]);

Currently, the problem is that the script editor isn't taking too kindly to my braces, '{'.  Does anyone know how to get this calculation done in my script?  I need this calc in the script because it will be used as a condition for NPrinting.

Any help is greatly appreciated.

1 Solution

Accepted Solutions
felipedl
Valued Contributor III

Re: LET variable, evaluate with braces

Hi Dustin,

The way your making it only works for charts, set expression is available for charts only.

Link for chart:

http://help.qlik.com/en-US/sense/September2017/Subsystems/Hub/Content/ChartFunctions/CounterAggregat...

Link for script count aggregation:

Count - função de script ‒ Qlik Sense

What you can do on script side is something like:

// Your first data load

Data:

Load

     *

From [Whatever];

// Count table:

tmp:

Load

     count([Stop Number]) as CountStopNumber

Resident Data

where len(IsLastShiftIsLastShift) > 0;


// gets the count from the previously loaded table

let vHasLastShift  = peek('CountStopNumber',0,'tmp');


drop table tmp;


hope it helps;

3 Replies
Khan_Mohammed
Honored Contributor II

Re: LET variable, evaluate with braces

  1. LET vHasLastShift = 'COUNT({<IsLastShiftIsLastShift={'*'}-{''}>}[Stop Number])'
JustinDallas
Valued Contributor II

Re: LET variable, evaluate with braces

The problem is that my Set Restriction has single-quotes itself, and it doesn't like those as that "ends" my statement.

felipedl
Valued Contributor III

Re: LET variable, evaluate with braces

Hi Dustin,

The way your making it only works for charts, set expression is available for charts only.

Link for chart:

http://help.qlik.com/en-US/sense/September2017/Subsystems/Hub/Content/ChartFunctions/CounterAggregat...

Link for script count aggregation:

Count - função de script ‒ Qlik Sense

What you can do on script side is something like:

// Your first data load

Data:

Load

     *

From [Whatever];

// Count table:

tmp:

Load

     count([Stop Number]) as CountStopNumber

Resident Data

where len(IsLastShiftIsLastShift) > 0;


// gets the count from the previously loaded table

let vHasLastShift  = peek('CountStopNumber',0,'tmp');


drop table tmp;


hope it helps;

Community Browser