Market Share

Created by Vijendra Sawant, Modified on Fri, 01 Dec 2023 at 04:33 PM by Vijendra Sawant

/*
Calculation Script name - WhizCalMarketshare
Description - Market share represents a product's or market's percentage of the overall sales in a given market or industry over a specified time period.
              Market Share of product P1 is calculated as (Sale of P1 / Total sale of all products)
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 WhizCalMarketShareLib.
                2.Function name : compute
                purpose : calculate marketshare.
                input parameters : metadataQuery 
                output parameters : dataframe
               
              
Key variables - query : implicit variable
                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("******************** WhizCalMarketshare **********************");

//Name for metadata query, this helps logging and identification of query.
query.name("WhizCalMarketshare_Query");

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


/*
 ** configuration to be set in calculation 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" and "apply_join_query" are flags used to switch between two calculation approaches implemented in a library script.

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

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

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 atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article