<?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: Chart Script - Conditional Check of Dimension in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Chart-Script-Conditional-Check-of-Dimension/m-p/2032754#M85095</link>
    <description>&lt;P&gt;Thanks for coming back. I stripped things back for simplicity to using the dimension name syntax. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I've managed to solve this using variables (as you suggested) in combination with MATCH().&lt;/P&gt;
&lt;P&gt;I've just tested using the straight equality operator, this also works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2023 12:04:43 GMT</pubDate>
    <dc:creator>Jim_Ogilvie</dc:creator>
    <dc:date>2023-02-01T12:04:43Z</dc:date>
    <item>
      <title>Chart Script - Conditional Check of Dimension</title>
      <link>https://community.qlik.com/t5/App-Development/Chart-Script-Conditional-Check-of-Dimension/m-p/2032739#M85093</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have successfully created a Chart Script that calculates the Year-Month variance in Margin% (see pic below).&lt;/P&gt;
&lt;P&gt;I would like to tidy this column up by putting a Null value when the Month dimension changes, so "Feb" in "2020", for example would contain '-'.&lt;/P&gt;
&lt;P&gt;I have tried to test the values of the 'Month' column, the current vs the previous as a trigger for blanking the Variance calculation, but it never equates to true:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;HCValue(Month,i) = HCValue(Month,i-1)&lt;/P&gt;
&lt;P&gt;Where 'i' is the counter variable in my loop, but this is never true...&lt;/P&gt;
&lt;P&gt;Chart Scripts are very new to Qlik, so there is not a great deal of knowledge base out there (&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/12989"&gt;@Michael_Tarallo&lt;/a&gt;&amp;nbsp;could you or Venkat comment, his article took me this far).&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChartScriptImg.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/99407i0EA9DA4F2C84928F/image-size/large?v=v2&amp;amp;px=999" role="button" title="ChartScriptImg.png" alt="ChartScriptImg.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 11:16:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Chart-Script-Conditional-Check-of-Dimension/m-p/2032739#M85093</guid>
      <dc:creator>Jim_Ogilvie</dc:creator>
      <dc:date>2023-02-01T11:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Chart Script - Conditional Check of Dimension</title>
      <link>https://community.qlik.com/t5/App-Development/Chart-Script-Conditional-Check-of-Dimension/m-p/2032751#M85094</link>
      <description>&lt;P&gt;You should be able to achieve this by putting the two values into variables and then comparing those. This is from a script I wrote for another purpose but should be appropriate here, though in your case you'll just need the comparison and a null value rather than the running total I used. Note that the code could probably be cleaner, this was just a proof of concept...&lt;/P&gt;
&lt;P&gt;I think you could also just skip the entire thing and compare &lt;STRONG&gt;HCValue(#hc1.dimension.2, J) = &lt;/STRONG&gt;&lt;STRONG&gt;HCValue(#hc1.dimension.2, J-1)&lt;/STRONG&gt; rather than referencing the dimension name which I think doesn't work well, but I'm not sure here. Scripts are kinda frustrating to write/test... &lt;/P&gt;
&lt;P&gt;Let P = HCNoRows(); // Get number of rows and set up required variable&lt;BR /&gt;Let vRunningTotal= 0;&lt;/P&gt;
&lt;P&gt;For J = 1 to P &lt;BR /&gt;// In this example, we will add a running total by Dim1 and Dim2 but this can be adjusted to any number of dimensions with any names&lt;BR /&gt;&lt;STRONG&gt;Let vDim = HCValue(#hc1.dimension.1, J) &amp;amp; HCValue(#hc1.dimension.2, J); // Add the current row dimension values&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Let vDimPrev = HCValue(#hc1.dimension.1, J-1) &amp;amp; HCValue(#hc1.dimension.2, J-1); // And the previous row values&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;// If the current row's dimensions match the previous row's, continue the running total&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;If vDim = vDimPrev then&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Let vRunningTotal = vRunningTotal + HCValue(Sales,J);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;else // If this row starts a new subtotal set, subtotal is just Sales&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Let vRunningTotal = HCValue(Sales,J);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;end if&lt;/STRONG&gt;&lt;BR /&gt;// Put the calculated subtotal into the Subtotal column&lt;BR /&gt;Put RunningTotal(J) = vRunningTotal&lt;/P&gt;
&lt;P&gt;Next;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 11:55:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Chart-Script-Conditional-Check-of-Dimension/m-p/2032751#M85094</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2023-02-01T11:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Chart Script - Conditional Check of Dimension</title>
      <link>https://community.qlik.com/t5/App-Development/Chart-Script-Conditional-Check-of-Dimension/m-p/2032754#M85095</link>
      <description>&lt;P&gt;Thanks for coming back. I stripped things back for simplicity to using the dimension name syntax. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I've managed to solve this using variables (as you suggested) in combination with MATCH().&lt;/P&gt;
&lt;P&gt;I've just tested using the straight equality operator, this also works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:04:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Chart-Script-Conditional-Check-of-Dimension/m-p/2032754#M85095</guid>
      <dc:creator>Jim_Ogilvie</dc:creator>
      <dc:date>2023-02-01T12:04:43Z</dc:date>
    </item>
  </channel>
</rss>

