<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: KPI measure off R.ScriptEval() as Expression in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419984#M14376</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you load the csv into qlik in the load script by the following:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Month",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; crvcnt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; htncnt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clrcnt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a1ccnt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trnd&lt;/P&gt;&lt;P&gt;FROM [lib://mycsv/sldsmp.csv]&lt;/P&gt;&lt;P&gt;(txt, codepage is 28591, embedded labels, delimiter is ',', msq); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the KPI object you set the following expression, then it works:&lt;/P&gt;&lt;P&gt;R.ScriptAggr('library(TTR);&lt;/P&gt;&lt;P&gt;library(forecast);&lt;/P&gt;&lt;P&gt;frcst &amp;lt;- forecast(ts(q$a1ccnt));&lt;/P&gt;&lt;P&gt;frcst1 &amp;lt;- as.data.frame(frcst[2]);&lt;/P&gt;&lt;P&gt;frcst2 &amp;lt;- round(frcst1[1,],0);'&lt;/P&gt;&lt;P&gt;, a1ccnt, Month)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jan 2018 15:49:58 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-01-02T15:49:58Z</dc:date>
    <item>
      <title>KPI measure off R.ScriptEval() as Expression</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419981#M14373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to grab a value from R using R.ScriptEval() for KPI measure. The R code works and produces a discrete value. The Expression is "OK" ; but the KPI produces null (nothing, just a dash). Yes, Rserve and SSEtoRServe are both on.&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the Expression I am using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;R.ScriptEval('library(TTR);library(forecast);newdata &amp;lt;-read.csv("sldsmp.csv");frcst &amp;lt;-forecast(ts(q$newdata$a1ccnt));frcst1 &amp;lt;-as.data.frame(q$frcst[2]);frcst2 &amp;lt;-round(q$frcst1[1,],0);q$frcst2')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the R code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;library(TTR)&lt;/P&gt;&lt;P&gt;library(forecast)&lt;/P&gt;&lt;P&gt;newdata &amp;lt;-read.csv("C:/&amp;lt;...&amp;gt;/Documents/Qlik/sldsmp.csv")&lt;/P&gt;&lt;P&gt;frcst &amp;lt;-forecast(ts(newdata$a1ccnt))&lt;/P&gt;&lt;P&gt;frcst1 &amp;lt;-as.data.frame(frcst[2])&lt;/P&gt;&lt;P&gt;frcst2 &amp;lt;-round(frcst1[1,],0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;removing "q$" in all but first instance does not make a difference.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the .csv file I am referencing:&lt;/P&gt;&lt;P&gt;See attachment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oguchi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2024 09:02:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419981#M14373</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T09:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: KPI measure off R.ScriptEval() as Expression</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419982#M14374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Oruchi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ScriptEval function takes a vector as input and returns a vector. This may not be what you want in a KPI object. Have a look here: &lt;A href="https://github.com/qlik-oss/sse-r-plugin/blob/master/GetStarted.md" title="https://github.com/qlik-oss/sse-r-plugin/blob/master/GetStarted.md"&gt;sse-r-plugin/GetStarted.md at master · qlik-oss/sse-r-plugin · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think for a KPI object it would be better to use the ScriptAggr function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another suggestion would be to load the data in the CSV into your qlik datamodel and then pass the values as a q$ parameter to your forcast call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it would look something like&lt;/P&gt;&lt;P&gt;R.ScriptAggr('library(TTR);library(forecast);frcst &amp;lt;-forecast(ts(q$newdata,$a1ccnt));frcst1 &amp;lt;-as.data.frame(q$frcst[2]);frcst2 &amp;lt;-round(q$frcst1[1,],0);q$frcst2', data as newdata);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2017 08:00:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419982#M14374</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-20T08:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: KPI measure off R.ScriptEval() as Expression</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419983#M14375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Bas:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for helping, but this did not work for me (yes, my csv file is script-loaded) because &lt;/P&gt;&lt;P&gt;&amp;lt;...data as newdata&amp;gt; at the end of the expression&amp;nbsp; triggers the Error, "Bad field name: data"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Nov 2017 05:35:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419983#M14375</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-21T05:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: KPI measure off R.ScriptEval() as Expression</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419984#M14376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you load the csv into qlik in the load script by the following:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Month",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; crvcnt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; htncnt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clrcnt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a1ccnt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trnd&lt;/P&gt;&lt;P&gt;FROM [lib://mycsv/sldsmp.csv]&lt;/P&gt;&lt;P&gt;(txt, codepage is 28591, embedded labels, delimiter is ',', msq); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the KPI object you set the following expression, then it works:&lt;/P&gt;&lt;P&gt;R.ScriptAggr('library(TTR);&lt;/P&gt;&lt;P&gt;library(forecast);&lt;/P&gt;&lt;P&gt;frcst &amp;lt;- forecast(ts(q$a1ccnt));&lt;/P&gt;&lt;P&gt;frcst1 &amp;lt;- as.data.frame(frcst[2]);&lt;/P&gt;&lt;P&gt;frcst2 &amp;lt;- round(frcst1[1,],0);'&lt;/P&gt;&lt;P&gt;, a1ccnt, Month)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jan 2018 15:49:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419984#M14376</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-02T15:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: KPI measure off R.ScriptEval() as Expression</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419985#M14377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I appreciate your help, @Tobias: this is the correct solution.&lt;/P&gt;&lt;P&gt;Worked perfect!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jan 2018 22:44:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/KPI-measure-off-R-ScriptEval-as-Expression/m-p/1419985#M14377</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-02T22:44:30Z</dc:date>
    </item>
  </channel>
</rss>

