Qlik Community

Qlik NPrinting Discussions

Discussion Board for collaboration on Qlik NPrinting.

drillnaut
Valued Contributor

Can't evaluate variable in NPrinting

Hello Everyone,

I've got some header text that I would like to include in an NPrinting Excel report.  It looks something like this in my Data Load section of Qlik Sense.

LET Today = timestamp(daystart(timestamp(today())) + maketime(6))

;

LET Yesterday = timestamp(daystart(timestamp(today()-1)) + maketime(6))

;

SET HeaderText = On-Time Exception Report for $(Yesterday) to $(Today)

I've tried pretty much everything including creating a variable in NPrinting and I alway get this.

Error: Garbage after expression: 'Exception'

What can I do to make my header get calculated properly.

ExpressionIssue.PNG

Any help is greatly appreciated.

1 Solution

Accepted Solutions
lech_miszkiewic
Honored Contributor III

Re: Can't evaluate variable in NPrinting

Try This & then just use variable in your NPrinitng Template

LET Today = timestamp(daystart(timestamp(today())) + maketime(6)); 

LET Yesterday = timestamp(daystart(timestamp(today()-1)) + maketime(6)); 

LETHeaderText = CHR(39)& 'On-Time Exception Report for '& '$(Yesterday)'&' to '&'$(Today)';

np1.pngnp2.png

np2.png

4 Replies
rsvebeck
Valued Contributor

Re: Can't evaluate variable in NPrinting

Did you try:

LET HeaderText = 'On-Time Exception Report for $(Yesterday) to $(Today)';

lech_miszkiewic
Honored Contributor III

Re: Can't evaluate variable in NPrinting

Try This & then just use variable in your NPrinitng Template

LET Today = timestamp(daystart(timestamp(today())) + maketime(6)); 

LET Yesterday = timestamp(daystart(timestamp(today()-1)) + maketime(6)); 

LETHeaderText = CHR(39)& 'On-Time Exception Report for '& '$(Yesterday)'&' to '&'$(Today)';

np1.pngnp2.png

np2.png

drillnaut
Valued Contributor

Re: Can't evaluate variable in NPrinting

Thanks Lech,

I think the main difference is that I have "SET" where you have "LET".  Once I dropped that in using your example it worked as I expected it to.

lech_miszkiewic
Honored Contributor III

Re: Can't evaluate variable in NPrinting

no worries,

Note also that by adding CHR(39) at the beggining of Header Text effectively we are producing string auch as:

'On-Time Exception Report for 11/05/2017 6:00:00 AM to 12:05/2017 6:00:00 AM.

The " ' " (single quote character) once moved to excel changes cell type to Text, so excel does not try to calculate formula like "=On-Time......"


hope this helps

regards

Lech

Community Browser