<?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: Variable in Paramaterized Set Analysis Expression in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757120#M58424</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/115370"&gt;@bc5891&lt;/a&gt;&amp;nbsp; below works.&lt;/P&gt;&lt;P&gt;Create a variable&amp;nbsp;&lt;STRONG&gt;vMetric&lt;/STRONG&gt; on front end instead of in script&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Put below expression in variable&lt;STRONG&gt; (Without "=")&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SUM({&amp;lt;DATA_SOURCE = {$1}, METRIC_CODE = {"$(=MaxString($2))"}&amp;gt;}AMOUNT)&lt;/P&gt;&lt;P&gt;Then below expression chart works&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;=$(vMetric("DB1",METRIC_CODE_1))&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 29 Oct 2020 16:46:23 GMT</pubDate>
    <dc:creator>Kushal_Chawda</dc:creator>
    <dc:date>2020-10-29T16:46:23Z</dc:date>
    <item>
      <title>Variable in Paramaterized Set Analysis Expression</title>
      <link>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757111#M58421</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having difficulty in the following expression and grateful for any help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;let vMetric = SUM({&amp;lt;DATA_SOURCE = {$1}, METRIC_CODE = {''$'&amp;amp;'(=(MaxString($2)))''}&amp;gt;}AMOUNT)&lt;/P&gt;&lt;P&gt;the expression in the front end would be:&lt;/P&gt;&lt;P&gt;vMetric(DB1,METRIC_CODE_1)&lt;/P&gt;&lt;P&gt;So, $2 would equal a selection from a field selected in the front end (e.g. METRIC_CODE_1).&amp;nbsp; When I have tried to follow other threads on this I haven't come across maxstring being used for a varying field selection.&amp;nbsp; Has anyone any ideas?&lt;/P&gt;&lt;P&gt;Reason I do this is there could be different filters (via different data islands) selected on different sheets to show different metrics.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The non-paramterized expression works like so:&lt;/P&gt;&lt;P&gt;SUM({&amp;lt; DATA_SOURCE = {'DB1'}, METRIC_CODE = {'$(=$(vMetric1))'} &amp;gt;}AMOUNT)&lt;/P&gt;&lt;P&gt;where vMetric1 = Maxstring(METRIC_CODE_1); When the user then selects a specific metric from metric_code_1 the expression updates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample data load would be like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA:&lt;BR /&gt;LOAD * inline&lt;BR /&gt;[&lt;BR /&gt;AMOUNT,DATA_SOURCE, METRIC_CODE&lt;BR /&gt;200,DB1,A,&lt;BR /&gt;1000,DB1 B&lt;BR /&gt;200,DB1,C,&lt;BR /&gt;1000,DB2,D&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;METRIC_CODE_1:&lt;BR /&gt;LOAD * inline&lt;BR /&gt;[&lt;BR /&gt;METRIC_CODE_1&lt;BR /&gt;A&lt;BR /&gt;B&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;METRIC_CODE_2:&lt;BR /&gt;LOAD * inline&lt;BR /&gt;[&lt;BR /&gt;METRIC_CODE_2&lt;BR /&gt;C&lt;BR /&gt;D&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;keen to hear any ideas. thanks&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 17:54:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757111#M58421</guid>
      <dc:creator>bc5891</dc:creator>
      <dc:date>2024-11-16T17:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Paramaterized Set Analysis Expression</title>
      <link>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757115#M58422</link>
      <description>&lt;P&gt;I would say maxstring() is used to ensure that the expression always returned a value. If you remove it and using just $2 the expression will only work if there is a single value selected within the metric-field. As far as there are more values selected or none the result would be NULL because it would be the same like only([metric-field]).&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 16:31:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757115#M58422</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2020-10-29T16:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Paramaterized Set Analysis Expression</title>
      <link>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757119#M58423</link>
      <description>&lt;P&gt;Thanks for the reply Marcus but I do not think that will work.&lt;BR /&gt;e.g.&amp;nbsp;vMetric(DB1, METRIC_CODE_1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above expression should&lt;/P&gt;&lt;P&gt;SUM Amount where DataSource = DB1, but also where METRIC_CODE = field selection in METRIC_CODE_1 (a data island)&lt;/P&gt;&lt;P&gt;I need what the &lt;STRONG&gt;field value&lt;/STRONG&gt; selection of METRIC_CODE_1 is, METRIC_CODE_1 is &lt;STRONG&gt;not the actual value&lt;/STRONG&gt; selection.&lt;/P&gt;&lt;P&gt;So, I want to be able to change it in another sheet to:&amp;nbsp;vMetric(DB1,METRIC_CODE_2) which then gives me the value when a single selection in field METRIC_CODE_2 is made, if that makes sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT - I re-read your message and get you understood what I meant &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 16:55:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757119#M58423</guid>
      <dc:creator>bc5891</dc:creator>
      <dc:date>2020-10-29T16:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Paramaterized Set Analysis Expression</title>
      <link>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757120#M58424</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/115370"&gt;@bc5891&lt;/a&gt;&amp;nbsp; below works.&lt;/P&gt;&lt;P&gt;Create a variable&amp;nbsp;&lt;STRONG&gt;vMetric&lt;/STRONG&gt; on front end instead of in script&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Put below expression in variable&lt;STRONG&gt; (Without "=")&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SUM({&amp;lt;DATA_SOURCE = {$1}, METRIC_CODE = {"$(=MaxString($2))"}&amp;gt;}AMOUNT)&lt;/P&gt;&lt;P&gt;Then below expression chart works&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;=$(vMetric("DB1",METRIC_CODE_1))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 29 Oct 2020 16:46:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757120#M58424</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-10-29T16:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Paramaterized Set Analysis Expression</title>
      <link>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757125#M58425</link>
      <description>&lt;P&gt;Hi Kush (and Marcus)&lt;/P&gt;&lt;P&gt;Thanks to both...&lt;/P&gt;&lt;P&gt;Both methods work ....... if the variable is created in the frontend - do you know of any workaround to have this in the backend as I like to keep all variables in a specific file?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 16:53:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757125#M58425</guid>
      <dc:creator>bc5891</dc:creator>
      <dc:date>2020-10-29T16:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Paramaterized Set Analysis Expression</title>
      <link>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757136#M58427</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/115370"&gt;@bc5891&lt;/a&gt;&amp;nbsp; I would advise to use front end variable itself because it will keep the expression as it is without manipulating it. Otherwise , if you use it in script, you may need to manipulate your expression like below to add the "$" within set analysis like below&lt;/P&gt;&lt;P&gt;let vMetric = '&lt;STRONG&gt;SUM({&amp;lt;DATA_SOURCE = {$1}, METRIC_CODE = {"&lt;/STRONG&gt;' &amp;amp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;chr(36)&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt;'&lt;STRONG&gt;(=maxstring($2))"}&amp;gt;}AMOUNT)&lt;/STRONG&gt;';&lt;/P&gt;&lt;P&gt;Then you can use the same expression&lt;/P&gt;&lt;PRE&gt;=$(vMetric("DB1",METRIC_CODE_1))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 17:14:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variable-in-Paramaterized-Set-Analysis-Expression/m-p/1757136#M58427</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-10-29T17:14:34Z</dc:date>
    </item>
  </channel>
</rss>

