<?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: Conditional script variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122781#M18731</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The set analysis looks fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to use the first expression, remember to &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/3779"&gt;Use Aggregation Functions!&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, try using the conditional in the aggregation, not outside of the aggregation function (that's the reason why the total line or the text box does not work as expected):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;avg(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;if([Grupo Equip.]= 'Forwarder' and Trimestre = '1º Trimestre', &lt;/SPAN&gt;[Meta DM]))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 30 Sep 2018 21:29:27 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2018-09-30T21:29:27Z</dc:date>
    <item>
      <title>Conditional script variable</title>
      <link>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122778#M18728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I need to create a variable with conditions:&lt;/P&gt;&lt;P&gt;This way bellow is not working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let vmeta_dm = if([Grupo Equip.]= 'Forwarder' and Trimestre = '1º Trimestre',avg([Meta DM]));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you guys help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2018 21:00:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122778#M18728</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-30T21:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional script variable</title>
      <link>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122779#M18729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In which context do you want to use this variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to define the variable in the script, but then use the variable e.g. in a UI chart expression (assumingly with dimensions [Grupo Equip.] and Trimestre), i.e. using a dollar sign expansion $(vmeta_dm), then you can define your variable like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SET vmeta_dm = if([Grupo Equip.]= 'Forwarder' and Trimestre = '1º Trimestre',avg([Meta DM]));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;If you want the variable to contain the avg([Meta DM]) for the conditions specified, then this won't work, you can't access and aggregate field values like this.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2018 21:10:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122779#M18729</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2018-09-30T21:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional script variable</title>
      <link>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122780#M18730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;tks 4 reply Stefan.&lt;/P&gt;&lt;P&gt;I wanna create the variable to calculate a total amount of fee for each type of machine and trimester:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/214762_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;the amount should be: 814.732.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In single table with sum of lines if works. But i need the final result in a text box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm getting null value in a text box with the e.g. you gave me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=$(vmeta_dm)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if I create a variable like this with set analysis out of script it works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=avg({1&amp;lt;[Grupo Equip.]={'Forwarder'},Trimestre={'1º Trimestre'}&amp;gt;} [Meta DM])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is this the best way to do that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2018 21:21:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122780#M18730</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-30T21:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional script variable</title>
      <link>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122781#M18731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The set analysis looks fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to use the first expression, remember to &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/3779"&gt;Use Aggregation Functions!&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, try using the conditional in the aggregation, not outside of the aggregation function (that's the reason why the total line or the text box does not work as expected):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;avg(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;if([Grupo Equip.]= 'Forwarder' and Trimestre = '1º Trimestre', &lt;/SPAN&gt;[Meta DM]))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Sep 2018 21:29:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Conditional-script-variable/m-p/122781#M18731</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2018-09-30T21:29:27Z</dc:date>
    </item>
  </channel>
</rss>

