<?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 Get the value from previous month in a line chart in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Get-the-value-from-previous-month-in-a-line-chart/m-p/2477773#M100403</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to build a line chart to display stock growth based on the previous month value, but I just can't get it to work.&lt;/P&gt;
&lt;P&gt;In the axis I have month as dimension and I want to compare the month value to the previous month value. For instance, January would display the result for (January stock value / December stock value) - 1, while February would display (February stock value / January stock value) - 1.&lt;/P&gt;
&lt;P&gt;I think I must use AddMonths. I guess it'd be something like this (except it's not working):&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Num(&lt;BR /&gt;(&lt;BR /&gt;Sum({1&amp;lt;year=$:: year&amp;gt;} stock_qty)&lt;BR /&gt;/&lt;BR /&gt;Sum({1&amp;lt;year=$:: year, month = {"$(=Month(AddMonths(month, -1)))"}&amp;gt;} stock_qty)&lt;BR /&gt;)&lt;BR /&gt;- 1&lt;BR /&gt;, '+##.##0,0%;-##.##0,0%')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;</description>
    <pubDate>Fri, 23 Aug 2024 14:21:58 GMT</pubDate>
    <dc:creator>pedrohenriqueperna</dc:creator>
    <dc:date>2024-08-23T14:21:58Z</dc:date>
    <item>
      <title>Get the value from previous month in a line chart</title>
      <link>https://community.qlik.com/t5/App-Development/Get-the-value-from-previous-month-in-a-line-chart/m-p/2477773#M100403</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to build a line chart to display stock growth based on the previous month value, but I just can't get it to work.&lt;/P&gt;
&lt;P&gt;In the axis I have month as dimension and I want to compare the month value to the previous month value. For instance, January would display the result for (January stock value / December stock value) - 1, while February would display (February stock value / January stock value) - 1.&lt;/P&gt;
&lt;P&gt;I think I must use AddMonths. I guess it'd be something like this (except it's not working):&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Num(&lt;BR /&gt;(&lt;BR /&gt;Sum({1&amp;lt;year=$:: year&amp;gt;} stock_qty)&lt;BR /&gt;/&lt;BR /&gt;Sum({1&amp;lt;year=$:: year, month = {"$(=Month(AddMonths(month, -1)))"}&amp;gt;} stock_qty)&lt;BR /&gt;)&lt;BR /&gt;- 1&lt;BR /&gt;, '+##.##0,0%;-##.##0,0%')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 14:21:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Get-the-value-from-previous-month-in-a-line-chart/m-p/2477773#M100403</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2024-08-23T14:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get the value from previous month in a line chart</title>
      <link>https://community.qlik.com/t5/App-Development/Get-the-value-from-previous-month-in-a-line-chart/m-p/2477865#M100414</link>
      <description>&lt;P&gt;Hi, set analysis is calculated before the table, so it won't use a diffrent value for each row or bar.&lt;/P&gt;
&lt;P&gt;You can use above, like:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Num(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sum({1&amp;lt;year=$:: year&amp;gt;} stock_qty)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Above(Sum({1&amp;lt;year=$:: year&amp;gt;} stock_qty))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;, '+##.##0,0%;-##.##0,0%')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But it won't work for the first value, so maybe you need another expression for the first value, checking when RowNo()=1 (The first chart value)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Num(If(RowNo()=1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;,Sum({1&amp;lt;year=$:: year&amp;gt;} stock_qty)&lt;BR /&gt;&amp;nbsp; /&amp;nbsp;Sum({1&amp;lt;year=$:: year, month = {"$(=Month(AddMonths(Min(month), -1)))"}&amp;gt;} stock_qty)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; ,Sum({1&amp;lt;year=$:: year&amp;gt;} stock_qty)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;/ Above(Sum({1&amp;lt;year=$:: year&amp;gt;} stock_qty))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;)- 1&lt;BR /&gt;, '+##.##0,0%;-##.##0,0%')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But probably it won't work because of the year, maybe you need a YearMonth field, so when you adds -1 month it knows it has to go the the previous year.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Another soution could be using the asof calendar&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Design/The-As-Of-Table/ba-p/1466130" target="_blank"&gt;https://community.qlik.com/t5/Design/The-As-Of-Table/ba-p/1466130&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Aug 2024 07:03:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Get-the-value-from-previous-month-in-a-line-chart/m-p/2477865#M100414</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2024-08-25T07:03:23Z</dc:date>
    </item>
  </channel>
</rss>

