Marketshare Growth

Created by Vijendra Sawant, Modified on Mon, 20 Nov, 2023 at 7:40 PM by Vijendra Sawant


/*
Calculation Script name - WhizCalMarketshareGrowth
Description - Market share growth is the growth in market share for the current time period vs the previous time period.
              market share growth of product P1= (market share of P1 in current period - market share of P1 in previous period)/(market share of P1 in previous period)
Product Version - v66
Script Version - 1.0

***Disclaimer - This is proprietary code of Whiz.AI. If you want to build on top of this computation script please make a copy/clone of this script and then alter the script which is copied or cloned. When version upgrade happens there are chances that this script may get modified hence any customization done by customer/partner developer may be overwritten.

Key Functions - 1.Function name : getComputationObj
                purpose : get instance of class present in library script.
              
                2.Function name : compute
                purpose : calculate marketshareGrowth.
                input parameters : metadataQuery , object of WhizCalMarketShareLib
                output parameters : dataframe
                                        
Key variables - query : implicit variable
                WhizCalDynamicPeriodLib : The name of the object present in WhizCalDynamicPeriodLib.js(library script).
                                          execution scripts can call WhizCalDynamicPeriodLib scripts functions using given object.
                WhizCalMarketShareLib : The name of the object present in WhizCalMarketShareLib.js(library script).
                                         execution scripts can call WhizCalMarketShareLib scripts functions using given object.
*/
//**Start of Function code

log.info("******************** WhizCalMarketshareGrowth **********************");
//name for metadata query, this helps logging and identification of query
query.name("WhizCalMarketshareGrowth_Query");

//calling the function from library script 
WhizCalDynamicPeriodLib.getComputationObj().compute(query, WhizCalMarketShareLib.getComputationObj());


/*
 ** configuration to be set in Computation metric **

default_filter: 1.In this section, we have added the filter that should be applied by default.
        2.In this section's dynamicArgs sub-section,
         we have added product hierarchy in order to remove the products from filters.
         "dim_mix_flag": true - Do not remove product filter
                 false - Remove product filter
         "apply_join_query" : flag used to switch between two calculation approaches
                    true- if join query needs to enable
         "operator": Here we specify which type of operation we want to perform
         "subtraction": It is aggregation operation and same as Aggregation.subtraction

**The configuration below should be copied and pasted to calculate the Marketshare growth.*
*/

"default_filter": {
      "type": "in",
      "column": "Product Name",
      "values": [
        "Arobi"
      ],
      "dynamicArgs": {
        "operator": "subtraction",
        "dim_mix_flag": false,
        "product_hier": [
          "Product Name"
        ],
        "apply_join_query": false
      }
    }

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article