<?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 Expression works in table, but not as a variable in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526166#M107152</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This expression works perfectly well in a chart/table:&lt;/P&gt;&lt;P&gt;Max({&amp;lt;Year={'$(=Max(Year))'}&amp;gt;}Score)&lt;/P&gt;&lt;P&gt;It doesn't work as a variable.&lt;/P&gt;&lt;P&gt;set vTEST = Max({&amp;lt;Year={'$(=Max(Year))'}&amp;gt;}Score)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Aug 2025 15:04:30 GMT</pubDate>
    <dc:creator>zakpullen</dc:creator>
    <dc:date>2025-08-04T15:04:30Z</dc:date>
    <item>
      <title>Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526166#M107152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This expression works perfectly well in a chart/table:&lt;/P&gt;&lt;P&gt;Max({&amp;lt;Year={'$(=Max(Year))'}&amp;gt;}Score)&lt;/P&gt;&lt;P&gt;It doesn't work as a variable.&lt;/P&gt;&lt;P&gt;set vTEST = Max({&amp;lt;Year={'$(=Max(Year))'}&amp;gt;}Score)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 15:04:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526166#M107152</guid>
      <dc:creator>zakpullen</dc:creator>
      <dc:date>2025-08-04T15:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526167#M107153</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/31500"&gt;@zakpullen&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A few thoughts for your consideration:&lt;/P&gt;&lt;P&gt;- What's the purpose of using single quotes in the Set Analysis filter? If the Year field is numeric, then quotes are not needed. The reason for this question is that quotes are usually causing trouble when storing formulas in variables.&lt;/P&gt;&lt;P&gt;- When you say "doesn't work in a variable", what do you mean? What are you expecting to see as the value of the variable, and how are you using the variable in your measures?&lt;/P&gt;&lt;P&gt;The way it's presented, the variable should store the formula (not the result), and it should be used in a measure like this:&lt;/P&gt;&lt;P&gt;$(vTest)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;What exactly doesn't work? Can you share more details, screen shots, or a sample app?&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Oleg Troyansky&lt;/P&gt;&lt;P&gt;P.S.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Allow me to invite you to my &lt;A href="https://www.hpartner.at/qlik-expert-class-mit-oleg-troyansky-in-wien/anmeldung-qlik-expert-class-mit-oleg-troyansky/" target="_blank" rel="noopener"&gt;Qlik Expert Class&lt;/A&gt; that I'll be teaching in Vienna, Austria on September 22-24. I will be teaching advanced data modeling, advanced scripting, performance optimization, and advanced aggregation and Set Analysis techniques. You will learn the most advanced Qlik methodologies that will help you solve tough problems like this one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 15:16:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526167#M107153</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2025-08-04T15:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526178#M107155</link>
      <description>&lt;P&gt;you can try using $(&lt;SPAN&gt;vTEST)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 17:08:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526178#M107155</guid>
      <dc:creator>anat</dc:creator>
      <dc:date>2025-08-04T17:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526255#M107169</link>
      <description>&lt;P&gt;I've tried variations of the variable. The quotes were one variation, it doesn't work without them either.&lt;/P&gt;&lt;P&gt;The variable doesn't return a result when put into a straight table or chart. It returns a '-'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ta&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 08:56:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526255#M107169</guid>
      <dc:creator>zakpullen</dc:creator>
      <dc:date>2025-08-05T08:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526256#M107170</link>
      <description>&lt;P&gt;That's what doesn't work.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 08:57:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526256#M107170</guid>
      <dc:creator>zakpullen</dc:creator>
      <dc:date>2025-08-05T08:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526259#M107171</link>
      <description>&lt;P&gt;Is the &lt;STRONG&gt;Year&lt;/STRONG&gt; being passed when you edit the expression ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kaushi2020_0-1754384984850.png" style="width: 439px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/182548iDC3784B3029329B8/image-dimensions/439x119?v=v2" width="439" height="119" role="button" title="kaushi2020_0-1754384984850.png" alt="kaushi2020_0-1754384984850.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 09:10:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526259#M107171</guid>
      <dc:creator>Kaushik2020</dc:creator>
      <dc:date>2025-08-05T09:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526306#M107176</link>
      <description>&lt;P&gt;This works (returns the correct year when used in a table)&lt;/P&gt;&lt;P&gt;set yr = Max(TrustYr);&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 15:29:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526306#M107176</guid>
      <dc:creator>zakpullen</dc:creator>
      <dc:date>2025-08-05T15:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526445#M107216</link>
      <description>&lt;P&gt;UI expressions should rather not be defined within script-variables because the possible need of quotes and/or other variables and/or any $-sign expansion makes a valid syntax usually far more complex as there were any benefits.&lt;/P&gt;&lt;P&gt;An alternatively might be to define these expressions externally within a data-base or Excel and then reading this data within a loop and assigning the content per peek() to the variable (prevents any evaluation of the content at this time). You should have a lot of such expression-variables and good reasons for them to add this kind of complexity to your applications.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2025 15:10:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526445#M107216</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-08-06T15:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Expression works in table, but not as a variable</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526451#M107217</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/31500"&gt;@zakpullen&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;I get what you want, but it's not the right way..&lt;/P&gt;&lt;P&gt;Let me know if I can help you&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This: Max({&amp;lt;Year={'$(=Max(Year))'}&amp;gt;}Score)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1 - It will work in charts because charts "evaluate" the sentence as formula&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2 - set vTEST = Max({&amp;lt;Year={'$(=Max(Year))'}&amp;gt;}Score)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;- It wil store "as text" your variable ( remmember to do it with single quotes.;&lt;/P&gt;&lt;P&gt;- if you want to use this expression in charts , use $(vTEST) , instead of the formula]&lt;/P&gt;&lt;P&gt;- If you want to do it, store text to use as formula, try Master Items instead of variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3 - If you want to get the max score during script execution you need:&lt;/P&gt;&lt;P&gt;Temp:&lt;/P&gt;&lt;P&gt;Max(Year) as max_year&lt;/P&gt;&lt;P&gt;From yourqvd;&lt;/P&gt;&lt;P&gt;let vMaxYear = peek('max_year',0,'Temp');&lt;/P&gt;&lt;P&gt;Drop table Temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TempMaxScore&lt;/P&gt;&lt;P&gt;Load Max(Score) as MaxScore&lt;/P&gt;&lt;P&gt;from yourqvd&lt;/P&gt;&lt;P&gt;Where year = $(vMaxYear);&lt;/P&gt;&lt;P&gt;let vMaxScore =&amp;nbsp;peek('MaxScore',0,'TempMaxScore');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bye!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2025 16:42:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-works-in-table-but-not-as-a-variable/m-p/2526451#M107217</guid>
      <dc:creator>rafaelencinas</dc:creator>
      <dc:date>2025-08-06T16:42:02Z</dc:date>
    </item>
  </channel>
</rss>

