<?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: Challenge #3 Month over Month Growth Rate in Incorta Conundrums</title>
    <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3879#M20</link>
    <description>&lt;P&gt;Here is a video of a code-friendly solution! The script for the MV using PySpark is in the description. Hope you enjoy!&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=Xj6FpwT4fp8" target="_blank"&gt;https://www.youtube.com/watch?v=Xj6FpwT4fp8&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 03:02:50 GMT</pubDate>
    <dc:creator>LukeG</dc:creator>
    <dc:date>2023-03-10T03:02:50Z</dc:date>
    <item>
      <title>Challenge #3 Month over Month Growth Rate</title>
      <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3508#M9</link>
      <description>&lt;DIV id="bodyDisplay" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;As a Sales Analyst, I need your help to know how my company's&amp;nbsp;&lt;SPAN&gt;revenue grows throughout a period using the&amp;nbsp;month-over-month growth formula :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Month growth rate = (This month - Last month) / Last month)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I am looking for this insight:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-12-21 at 2.22.13 PM.png" style="width: 999px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/1840i800FD79AF853E177/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-12-21 at 2.22.13 PM.png" alt="Screen Shot 2022-12-21 at 2.22.13 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can use the attached Sales data and Date lookup data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know it is a little bit tricky, But&amp;nbsp; When you try it you will find it is fun&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Dec 2022 12:36:07 GMT</pubDate>
      <guid>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3508#M9</guid>
      <dc:creator>Rasha</dc:creator>
      <dc:date>2022-12-21T12:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge #3 Month over Month Growth Rate</title>
      <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3730#M15</link>
      <description>&lt;P&gt;Hi Rasha,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;My solution involved created a materialized view using the Spark SQL feature which created a table that showed , Year, Month, Mth Sum, and Previous Month Sum. I then loaded that Schema in and created a formula inside the insight to show the growth percentage. Im interested to see if you had the same solution. Ive attached my graphic below.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TCoomes_1-1675786914671.png" style="width: 801px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/1942i4DCCFB8CE2B3B6A7/image-dimensions/801x173?v=v2" width="801" height="173" role="button" title="TCoomes_1-1675786914671.png" alt="TCoomes_1-1675786914671.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 16:22:36 GMT</pubDate>
      <guid>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3730#M15</guid>
      <dc:creator>TCoomes</dc:creator>
      <dc:date>2023-02-07T16:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge #3 Month over Month Growth Rate</title>
      <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3731#M16</link>
      <description>&lt;P&gt;Great stuff&amp;nbsp;&lt;a href="https://community.incorta.com/t5/user/viewprofilepage/user-id/719"&gt;@TCoomes&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 16:41:05 GMT</pubDate>
      <guid>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3731#M16</guid>
      <dc:creator>JoeM</dc:creator>
      <dc:date>2023-02-07T16:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge #3 Month over Month Growth Rate</title>
      <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3761#M17</link>
      <description>&lt;P&gt;Not the most elegant, but I got the end result! Here is my solution:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create analyzer table named MONTHLY_REVENUE with 3 columns: Year, Month, Revenue&lt;/LI&gt;
&lt;LI&gt;Create analyzer table named PREVIOUS_MONTHLY_REVENUE with 3 columns: Year, Month, Previous Month Revenue&lt;/LI&gt;
&lt;LI&gt;Join Tables on Year and Month&lt;/LI&gt;
&lt;LI&gt;Create visualization with the Year, Month, Revenue, Previous Month Revenue, and Growth Rate using the formula provided.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;In step 2, you can represent the previous month revenue by adjusting the month by 1 year. After doing so, the sum of revenue will represent the previous month.&lt;/P&gt;
&lt;P&gt;Excited to see some other solutions!&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2023-02-14 at 11.50.59 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/1954i3A600E425581794F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2023-02-14 at 11.50.59 AM.png" alt="Screen Shot 2023-02-14 at 11.50.59 AM.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2023-02-14 at 11.52.06 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/1955iFB69843D8C8CF9DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2023-02-14 at 11.52.06 AM.png" alt="Screen Shot 2023-02-14 at 11.52.06 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 19:50:19 GMT</pubDate>
      <guid>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3761#M17</guid>
      <dc:creator>LukeG</dc:creator>
      <dc:date>2023-02-14T19:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge #3 Month over Month Growth Rate</title>
      <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3799#M18</link>
      <description>&lt;P&gt;I asked ChatGPT to answer this question, here is his reply&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;To calculate the month-over-month growth rate in Incorta, you will need to perform the following steps:

1. Join the `sales` and `months` tables on the `TIME_ID` column in the `sales` table and the `Date` column in the `months` table.
2. Create a calculated column in the joined table to calculate the revenue for each month by multiplying the `QUANTITY_SOLD` by the `AMOUNT_SOLD`.
3. Create two calculated columns in the joined table to calculate the revenue for each month and the previous month. To do this, you can use the following steps:
   a. Use the `Window` function to create a sliding window over the rows in the joined table, ordered by the `Date` column in the `months` table.
   b. Use the `LAG` function to retrieve the revenue value for the previous month for each row in the joined table.
   c. Use an `IF` statement to handle the case where there is no previous month for the first row in the joined table. In this case, you can set the revenue for the previous month to 0.
4. Create a calculated column in the joined table to calculate the month-over-month growth rate using the following formula:
   `Month growth rate = (This month revenue - Last month revenue) / Last month revenue`
5. Group the data by the `Month_Name` column to see the revenue for each month.
6. Create a visualization such as a line chart or bar chart to display the month-over-month growth rate.

This is a more detailed outline of the steps needed to calculate the month-over-month growth rate in Incorta, including the exact formula that will be used. The specific details of the calculation will depend on the data and the requirements of your project.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Then asked him for more details on Step 3, and here it is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;To calculate the revenue for each month and the previous month in Incorta, you can use the following formula in a calculated column:

```
CASE 
  WHEN ROW_NUMBER() OVER (ORDER BY "Date") = 1 THEN 0 
  ELSE LAG("Revenue", 1, 0) OVER (ORDER BY "Date") 
END
```

In this formula, the `ROW_NUMBER()` function is used to determine the row number for each row in the joined table, ordered by the `Date` column in the `months` table. The `LAG` function is used to retrieve the revenue value for the previous month for each row in the joined table. The `CASE` statement is used to handle the case where there is no previous month for the first row in the joined table. In this case, the revenue for the previous month is set to 0.

This formula can be used to create two calculated columns in the joined table, one for the revenue for each month and one for the revenue for the previous month.&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 20 Feb 2023 14:59:23 GMT</pubDate>
      <guid>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3799#M18</guid>
      <dc:creator>oabdelkarim</dc:creator>
      <dc:date>2023-02-20T14:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge #3 Month over Month Growth Rate</title>
      <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3879#M20</link>
      <description>&lt;P&gt;Here is a video of a code-friendly solution! The script for the MV using PySpark is in the description. Hope you enjoy!&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=Xj6FpwT4fp8" target="_blank"&gt;https://www.youtube.com/watch?v=Xj6FpwT4fp8&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 03:02:50 GMT</pubDate>
      <guid>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3879#M20</guid>
      <dc:creator>LukeG</dc:creator>
      <dc:date>2023-03-10T03:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge #3 Month over Month Growth Rate</title>
      <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3960#M25</link>
      <description>&lt;P&gt;My result:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="challenge#3.png" style="width: 999px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2045i9B8A46896322401B/image-size/large?v=v2&amp;amp;px=999" role="button" title="challenge#3.png" alt="challenge#3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In order to compare revenue month by month, we will need to find the previous revenue for the current month. I find it is easy to solve this by leveraging SQL Query. We can do so by creating either an Incorta SQL table or Incorta Materialized View.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My solution:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. upload all files, create schema and add tables to the scheme&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Add materialized view (&lt;/SPAN&gt;&lt;STRONG&gt;Month_over_Month_Revenue&lt;/STRONG&gt;&lt;SPAN&gt;), select language as Spark SQL. (see following code)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. Create Join between &lt;/SPAN&gt;&lt;STRONG&gt;Date_US&lt;/STRONG&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;STRONG&gt;Month_over_Month_Revenue&lt;/STRONG&gt;&lt;SPAN&gt; on &lt;/SPAN&gt;&lt;STRONG&gt;CALENDAR_MONTH_NUMBER&lt;/STRONG&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;STRONG&gt;MONTH_NUMBER&lt;/STRONG&gt;&lt;SPAN&gt; (This helps us show Month Name in the insight)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4. Create insight, choose Aggregated table.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;drag &lt;/SPAN&gt;&lt;STRONG&gt;CALENDAR_YEAR&lt;/STRONG&gt;&lt;SPAN&gt; (from &lt;/SPAN&gt;&lt;STRONG&gt;Month_over_Month_Revenue&lt;/STRONG&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;STRONG&gt;Month_Name&lt;/STRONG&gt;&lt;SPAN&gt; (from &lt;/SPAN&gt;&lt;STRONG&gt;Date_US&lt;/STRONG&gt;&lt;SPAN&gt;) to grouping dimension. Select &lt;/SPAN&gt;&lt;STRONG&gt;Month_Name &lt;/STRONG&gt;&lt;SPAN&gt;and&lt;/SPAN&gt; &lt;SPAN&gt;add &lt;/SPAN&gt;&lt;STRONG&gt;Month_Number&lt;/STRONG&gt;&lt;SPAN&gt; (from Date_US) into sort by in Ascending order&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;drag &lt;/SPAN&gt;&lt;STRONG&gt;Current_Revenue&lt;/STRONG&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;Previous_Month_Revenue&lt;/STRONG&gt;&lt;SPAN&gt; (from &lt;/SPAN&gt;&lt;STRONG&gt;Month_over_Month_Revenue&lt;/STRONG&gt;&lt;SPAN&gt;) to measure.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;add formula to measure, enter &lt;/SPAN&gt;&lt;STRONG&gt;(Current_Revenue - Previous_Month_Revenue) / Previous_Month_Revenue, &lt;/STRONG&gt;&lt;SPAN&gt;name this column as Growth. Create two conditions (if Growth &amp;gt; 0 and if Growth &amp;lt;= 0), choose a different background color for each.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;WITH cur as (
    SELECT
        CALENDAR_YEAR as CALENDAR_YEAR,
        CALENDAR_MONTH_NUMBER as CALENDAR_MONTH_NUMBER,
        SUM(AMOUNT_SOLD) as AMOUNT_SOLD
    FROM
        sch_CommunityChallenge3.SALES__1_
    GROUP BY
        CALENDAR_YEAR,
        CALENDAR_MONTH_NUMBER
)
SELECT
    CALENDAR_YEAR,
    CALENDAR_MONTH_NUMBER,
    AMOUNT_SOLD as Current_Revenue,
    LAG(AMOUNT_SOLD, 1) OVER (
        ORDER BY
            CALENDAR_YEAR,
            CALENDAR_MONTH_NUMBER
    ) as Previous_Month_Revenue
FROM
    cur;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 18:00:28 GMT</pubDate>
      <guid>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/3960#M25</guid>
      <dc:creator>zhong</dc:creator>
      <dc:date>2023-03-27T18:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Challenge #3 Month over Month Growth Rate</title>
      <link>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/4024#M29</link>
      <description>&lt;P&gt;My solution doesn't need any SQL code or new tables.&lt;/P&gt;&lt;P&gt;1. Add a formula column Month_Start_Date to sales table:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;monthStartDate(&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sch_CommunityChallenge3.SALES__1_.TIME_ID&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;2. Go to insight, select aggregated table, group by Month_Start_Date, previous month revenue can be calculated with Incorta formula:&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;sum(&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sch_CommunityChallenge3.SALES__1_.AMOUNT_SOLD,&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ago(&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sch_CommunityChallenge3.SALES__1_.Month_Start_Date,&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1,&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'month'&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;3. Calculate growth over month based on last step&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StevenPeng_0-1680290563170.png" style="width: 999px;"&gt;&lt;img src="https://community.incorta.com/t5/image/serverpage/image-id/2073iC654574E2319EFED/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="StevenPeng_0-1680290563170.png" alt="StevenPeng_0-1680290563170.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 31 Mar 2023 19:24:43 GMT</pubDate>
      <guid>https://community.incorta.com/t5/incorta-conundrums/challenge-3-month-over-month-growth-rate/m-p/4024#M29</guid>
      <dc:creator>StevenPeng</dc:creator>
      <dc:date>2023-03-31T19:24:43Z</dc:date>
    </item>
  </channel>
</rss>

