Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
martynlloyd
Partner - Creator III
Partner - Creator III

Use script to write HTML

Hi everyone,

I'm trying to produce an html snippet, using just scripting.  I am unable to use macros in this context.

So close, but not there; the output looks like this:

<HTML>,HTML
<head>,
<style>,
body {background-color:lightgrey},
h1   {color:blue},
p    {color:green},
</style>,
</head>,
<body>,
,2536
</body>,

How can I resolve the fact that I have two fields - the editor will not accept <HTML> as a field name...

here is the script

OrderMassTotal:
LOAD 
     KPIYear,
    
Sum(Volume) as [TotalRetailOrders]
Resident KPIFACTS
Where KPIID='S12' and KPIYear=2015
Group By KPIYear;

OrderHeadline:
Load * Inline [
<HTML>
<head>
<style>
  body {background-color:lightgrey}
  h1   {color:blue}
  p    {color:green}
</style>
</head>
<body>
]
;

Concatenate
Load
Peek(TotalRetailOrders, -1, 'OrderMassTotal') as HTML
AutoGenerate(1)
;

Concatenate
Load * Inline [
<HTML>
</body>
]
;

STORE OrderHeadline into [$(vQVDPath)\KPIOrderRetailHeadline.html] (txt);

Best regards,

Marty.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You were nearly there. Just change this line:

Peek(TotalRetailOrders, -1, 'OrderMassTotal') as HTML

It should read:

Peek('TotalRetailOrders', -1, 'OrderMassTotal') as [<HTML>]

Then it should work - it did when I tested it. This is what the output file contained (you will have a different value from the 500 below):

<HTML>

<head>

<style>

body {background-color:lightgrey}

h1   {color:blue}

p    {color:green}

</style>

</head>

<body>

500

</body>

HTH

Jonathan

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

View solution in original post

3 Replies
marcus_sommer

Maybe this is helpful for you:

OrderHeadline:

Load *, rowno() as RowNo Inline [

HTML-Code

<HTML>

<head>

<style>

  body {background-color:lightgrey}

  h1   {color:blue}

  p    {color:green}

</style>

</head>

<body>

];

HTML:

NoConcatenate Load

    concat([HTML-Code], chr(10), RowNo) as [HTML-Code]

Resident OrderHeadline;

drop tables OrderHeadline;

- Marcus

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You were nearly there. Just change this line:

Peek(TotalRetailOrders, -1, 'OrderMassTotal') as HTML

It should read:

Peek('TotalRetailOrders', -1, 'OrderMassTotal') as [<HTML>]

Then it should work - it did when I tested it. This is what the output file contained (you will have a different value from the 500 below):

<HTML>

<head>

<style>

body {background-color:lightgrey}

h1   {color:blue}

p    {color:green}

</style>

</head>

<body>

500

</body>

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
martynlloyd
Partner - Creator III
Partner - Creator III
Author

Thanks Jonathan!

I should have seen that one.

M.