/* Calculation Script name - WhizCalPreviousMarketshare Description - Previous market share is used to calculate the percentage share of a particular product in a specific market, for previous time period. Previous period is a period of time that has recently ended or occurred before the current period. For time period T1, market share is 100 and for time period T2, market share is 150, where T1 is current time period set in the context. Previous Market share TRx = 150. 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 : computePrevious purpose : calculate the market share for previous time period. 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("******************** WhizCalPreviousMarketshare **********************"); //name for metadata query, this helps logging and identification of query query.name("WhizCalPreviousMarketshare_Query"); //calling the function from library script WhizCalDynamicPeriodLib.getComputationObj().computePrevious(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. "apply_join_query" : flag used to switch between two calculation approaches true- if join query needs to enable ** The configuration below should be copied and pasted to calculate the previous market share.* */ "default_filter": { "type": "in", "column": "Product Name", "values": [ "Plabenil" ], "dynamicArgs": { "threshold": 50000, "product_hier": [ "Product Name", "Product Strength" ], "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
Feedback sent
We appreciate your effort and will try to fix the article