<?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: User-defined functions equivalent in Qlik Sense in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322530#M28577</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first attempt I tried to put the definition in an application variable and noticed that the keyword "Set" was not recognized. Once I put the variable definition in the load script and then I was able to call the "function" in the application just as stated. As always, I appreciate the help! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are there any examples that show this technique for more complex "functions"? For example, a for loop or do while loop... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 May 2017 13:54:38 GMT</pubDate>
    <dc:creator>wdchristensen</dc:creator>
    <dc:date>2017-05-25T13:54:38Z</dc:date>
    <item>
      <title>User-defined functions equivalent in Qlik Sense</title>
      <link>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322526#M28573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;From time to time I find myself rewriting the same code over and over again. A simple example might be something like removing special characters that are not stripped by the default trim function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: fuchsia;"&gt;Replace&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: fuchsia;"&gt;Replace&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: black;"&gt;myFieldName&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;char&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: black;"&gt;194&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;),&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: red;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;),&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;char&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: black;"&gt;160&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;),&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: red;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Now suppose I want to make a custom trim that will accept a field name and perform a replace action. Ideally, I would like this new function to be usable in the load script and as well as in the application. How can this functionality be accomplished to prevent unnecessary code duplication.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 May 2017 17:03:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322526#M28573</guid>
      <dc:creator>wdchristensen</dc:creator>
      <dc:date>2017-05-23T17:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: User-defined functions equivalent in Qlik Sense</title>
      <link>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322527#M28574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use a variable with parameters for it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set eReplace = &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: fuchsia;"&gt;Replace&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: fuchsia;"&gt;Replace&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;$1&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;char&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: black;"&gt;194&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;),&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: red;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;),&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;char&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: black;"&gt;160&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;),&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: red;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: gray;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then you call it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;$(eReplace(&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: black;"&gt;myFieldName&lt;/SPAN&gt;)) as &lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: black;"&gt;myFieldName&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2017 07:08:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322527#M28574</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2017-05-24T07:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: User-defined functions equivalent in Qlik Sense</title>
      <link>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322528#M28575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply. &lt;SPAN style="font-size: 10pt;"&gt;From what I can gather, this solution is for use in the load script. In my example this would probably work fine but in reality I am trying to show the truth evaluation for my set analysis conditions that I have put in variables as explained in another post (&lt;/SPAN&gt;&lt;A class="jive-link-thread-small" data-containerid="2156" data-containertype="14" data-objectid="261534" data-objecttype="1" href="https://community.qlik.com/thread/261534?sr=stream"&gt;https://community.qlik.com/thread/261534?sr=stream&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So essentially I am repeating this measure formula 50 times:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if((SUM({&amp;lt;$(vMarket)&amp;gt;} 2)) - (SUM({&amp;lt;1=1&amp;gt;} 1))=1,'True','False')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I just keep changing vMarket to the next set analysis T/F condition. I am not sure I like this implementation so I really want to put it in a function so when I learn a better way I can make the change in one location and cascade the changes with as little rework as possible. Any suggestions? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2017 14:20:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322528#M28575</guid>
      <dc:creator>wdchristensen</dc:creator>
      <dc:date>2017-05-24T14:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: User-defined functions equivalent in Qlik Sense</title>
      <link>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322529#M28576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The solution Marcus proposed - variables with parameters - works in both load script and chart expressions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 May 2017 14:32:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322529#M28576</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2017-05-24T14:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: User-defined functions equivalent in Qlik Sense</title>
      <link>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322530#M28577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first attempt I tried to put the definition in an application variable and noticed that the keyword "Set" was not recognized. Once I put the variable definition in the load script and then I was able to call the "function" in the application just as stated. As always, I appreciate the help! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are there any examples that show this technique for more complex "functions"? For example, a for loop or do while loop... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 May 2017 13:54:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322530#M28577</guid>
      <dc:creator>wdchristensen</dc:creator>
      <dc:date>2017-05-25T13:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: User-defined functions equivalent in Qlik Sense</title>
      <link>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322531#M28578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately, you can't use the technique with loops (easily).&amp;nbsp; It needs to be a single expression, not a series of statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 May 2017 17:12:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/User-defined-functions-equivalent-in-Qlik-Sense/m-p/1322531#M28578</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2017-05-25T17:12:02Z</dc:date>
    </item>
  </channel>
</rss>

