<?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: Adjust Set Expression based on Dimension value on x-axis in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Adjust-Set-Expression-based-on-Dimension-value-on-x-axis/m-p/2163179#M94428</link>
    <description>&lt;P&gt;For anyone maybe interested, I found a (bit hacky) solution, so Marcus' idea to partly precalculate the result in the script would be the more viable option.&lt;/P&gt;
&lt;P&gt;I created a variable with a&lt;STRONG&gt; ValueList&lt;/STRONG&gt; of the user-selected month and the 12 previous month and joined them with &lt;STRONG&gt;Concat()&lt;/STRONG&gt; - this is my synthetic dimension for the chart.&lt;/P&gt;
&lt;P&gt;That dimension can now be used in a Pick/Match clause in the chart script to pick the right version - if the year is the current year, pick the actual month, else if the year is already over, pick the latest version.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2024 08:02:37 GMT</pubDate>
    <dc:creator>alliedarmour</dc:creator>
    <dc:date>2024-01-19T08:02:37Z</dc:date>
    <item>
      <title>Adjust Set Expression based on Dimension value on x-axis</title>
      <link>https://community.qlik.com/t5/App-Development/Adjust-Set-Expression-based-on-Dimension-value-on-x-axis/m-p/2162464#M94356</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;
&lt;P&gt;I'm stuck at the following problem: I have date values (month and year) on the x-axis and some Sum formula with a set expression as my measure in a bar chart.&lt;/P&gt;
&lt;P&gt;Now, this chart always shows the last 12 months, based on the current selection of year and (optionally) month.&lt;/P&gt;
&lt;P&gt;Now the problem is this: The values on the y-axis have 3 "versions"; so let's say value X in version 1 is 2, version 2 is 4 and version 3 is 6.&lt;/P&gt;
&lt;P&gt;Now, for a year which is already finished I want to take only the highest version of the values, for a pending year the most recent.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Example: I select Year 2024 and month January -&amp;gt; the chart shows the dimensions: 01-2024, 12-2023, ..., 01-2023.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Now if the year changes to 2023 (for 12-2023) I need the latest possible version (3) and for 01-2024 the most recent (let's say 1).&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;I tried the following, but it didn't work out as I can't seem to sum the values depending on the x-axis:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if(Year(AddMonths(Max(discharge_date),&amp;nbsp; -12)) &amp;lt; Max(year),&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Sum({$&amp;lt;ischarge_date = {"&amp;gt;$(=AddMonths(Max(ischarge_date), -12))&amp;lt;=$(=Date(Max(ischarge_date)))"}, Version = {3}, MonatNummer = , year= &amp;gt;} Value),&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Sum({$&amp;lt;ischarge_date = {"&amp;gt;$(=AddMonths(Max(ischarge_date), -12))&amp;lt;=$(=Date(Max(ischarge_date)))"}, Version = {1}, MonatNummer = , year= &amp;gt;} Value)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The if-condition (logically) always evaluates to true, so this doesn't work - is there any possibility to do this kind of calculation?&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 14:25:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Adjust-Set-Expression-based-on-Dimension-value-on-x-axis/m-p/2162464#M94356</guid>
      <dc:creator>alliedarmour</dc:creator>
      <dc:date>2024-01-17T14:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adjust Set Expression based on Dimension value on x-axis</title>
      <link>https://community.qlik.com/t5/App-Development/Adjust-Set-Expression-based-on-Dimension-value-on-x-axis/m-p/2162686#M94383</link>
      <description>&lt;P&gt;With your described dataset it's not solvable per set analysis because it's mixing periods with different versions - and if they need a different calculation you will need appropriate if-loops to query them and then branching into the wanted calculation. That's currently not be working as expected means that the if-query isn't correct respectively suitable, for example being not granular enough and/or querying in the wrong order or ...&lt;/P&gt;
&lt;P&gt;I think I would tend to a different approach and flagging the information if the version is the highest one in the script, maybe with something like:&lt;/P&gt;
&lt;P&gt;m: mapping load KEY, max(Version) from X group by KEY;&lt;/P&gt;
&lt;P&gt;t: load *, -(Version=applymap('m', KEY, 0)) as Flag from X;&lt;/P&gt;
&lt;P&gt;and then the Flag could be queried in the set analysis and/or the field could be used as selection and/or as multiplier to the relevant calculations (instead of a simple TRUE/FALSE flag the field might be also created as offset-value to the highest version).&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 07:12:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Adjust-Set-Expression-based-on-Dimension-value-on-x-axis/m-p/2162686#M94383</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-01-18T07:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adjust Set Expression based on Dimension value on x-axis</title>
      <link>https://community.qlik.com/t5/App-Development/Adjust-Set-Expression-based-on-Dimension-value-on-x-axis/m-p/2163179#M94428</link>
      <description>&lt;P&gt;For anyone maybe interested, I found a (bit hacky) solution, so Marcus' idea to partly precalculate the result in the script would be the more viable option.&lt;/P&gt;
&lt;P&gt;I created a variable with a&lt;STRONG&gt; ValueList&lt;/STRONG&gt; of the user-selected month and the 12 previous month and joined them with &lt;STRONG&gt;Concat()&lt;/STRONG&gt; - this is my synthetic dimension for the chart.&lt;/P&gt;
&lt;P&gt;That dimension can now be used in a Pick/Match clause in the chart script to pick the right version - if the year is the current year, pick the actual month, else if the year is already over, pick the latest version.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 08:02:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Adjust-Set-Expression-based-on-Dimension-value-on-x-axis/m-p/2163179#M94428</guid>
      <dc:creator>alliedarmour</dc:creator>
      <dc:date>2024-01-19T08:02:37Z</dc:date>
    </item>
  </channel>
</rss>

