# Marketshare queries

Marketshare is a performance metric used to measure a company's sales or market share relative to the total sales or performance of a specific market or industry. The following documentation includes syntax and examples that will help you understand how to accurately calculate marketshare and get valuable insights into your company's performance.

### **Syntax**

Marketshare <mark style="color:green;">**KPI**</mark> for <mark style="color:red;">**target variable**</mark> for/by <mark style="color:blue;">**filters/dimensions**</mark>

* <mark style="color:green;">**Green-colored text**</mark> represents the KPI (key performance indicator) that you want to measure, such as *TRx* or *NRx*. It is always the word that follows “Marketshare”.
* <mark style="color:red;">**Red-colored text**</mark> is the target variable or marketshare filter (i.e., filter in numerator which will not be present in the denominator). This is the text that follows the KPI; unless there is a "vs" or "compared to" keyword, in which case it would be the first two words.
* <mark style="color:blue;">**Blue-colored text**</mark> is the list of global filters (the parameters you want to apply in your marketshare analysis). There could be multiple filters after a "for" or "in”.

{% hint style="info" %}
For refined search query results, please make sure to add a time period. Example: *for last 4 weeks, in 2023*
{% endhint %}

### **Examples**

#### Marketshare <mark style="color:green;">**dollar sales**</mark> for <mark style="color:red;">**Brand A**</mark> in <mark style="color:blue;">**2019**</mark>

<figure><img src="https://977923713-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJHwf1QFuv1BRPzfSnL2Z%2Fuploads%2FksKUor0A9K1MLzXyk60y%2Fimage.png?alt=media&#x26;token=bff5c49e-e7fb-432b-9474-16e64ad2be4a" alt="" width="326"><figcaption></figcaption></figure>

#### Marketshare <mark style="color:green;">**dollar sales**</mark> for <mark style="color:red;">**Brand A**</mark> vs <mark style="color:red;">**Brand B**</mark> for <mark style="color:blue;">**New York**</mark> for <mark style="color:blue;">**Derm**</mark>           &#x20;

is the same as

#### Marketshare <mark style="color:green;">**dollar sales**</mark> for <mark style="color:red;">**Brand A**</mark> compared to <mark style="color:red;">**Brand B**</mark> for <mark style="color:blue;">**Derm**</mark> for <mark style="color:blue;">**New York**</mark>

<figure><img src="https://977923713-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJHwf1QFuv1BRPzfSnL2Z%2Fuploads%2F2xYPGuElwdi70ZBaMbdc%2Fimage.png?alt=media&#x26;token=5809a231-17e9-4285-832a-3e60d39a1033" alt="" width="563"><figcaption></figcaption></figure>

#### **Marketshare&#x20;**<mark style="color:green;">**dollar sales**</mark>**&#x20;for&#x20;**<mark style="color:red;">**brand**</mark>**&#x20;by&#x20;**<mark style="color:blue;">**state**</mark>

This shows the multiple values for each brand for a particular state, where the different brands would sum upto 100%

<figure><img src="https://977923713-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJHwf1QFuv1BRPzfSnL2Z%2Fuploads%2F3fTGXBtY1V4Fedbnrfzd%2Fimage.png?alt=media&#x26;token=eb9a01da-37ea-4220-ac3d-26fb4c5225f3" alt="" width="375"><figcaption></figcaption></figure>

#### **Marketshare&#x20;**<mark style="color:green;">**dollar sales**</mark>**&#x20;for&#x20;**<mark style="color:red;">**state**</mark>**&#x20;by&#x20;**<mark style="color:blue;">**brand**</mark>

This shows the multiple values for each brand with the shares of state among other tiers (where the different brands would not sum upto 100%)

<figure><img src="https://977923713-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJHwf1QFuv1BRPzfSnL2Z%2Fuploads%2FNgWo0fGefEEQRTRRrVHw%2Fimage.png?alt=media&#x26;token=ea7e250b-e265-4a6e-93fa-2d518060f9fe" alt="" width="375"><figcaption></figcaption></figure>

**Marketshare&#x20;**<mark style="color:green;">**dollar sales**</mark>**&#x20;for&#x20;**<mark style="color:red;">**Brand X**</mark>**&#x20;by&#x20;**<mark style="color:blue;">**segment**</mark>

This shows the share of sales Brand X has within each segment (which does not add up to 100%)

<figure><img src="https://977923713-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJHwf1QFuv1BRPzfSnL2Z%2Fuploads%2F4uc3mKBHNVqXCut8lFcO%2Fimage.png?alt=media&#x26;token=4f6a886a-ee32-4ab1-99e0-dbd7a8c506bb" alt="" width="375"><figcaption></figcaption></figure>

#### **Marketshare&#x20;**<mark style="color:green;">**dollar sales**</mark>**&#x20;for/by&#x20;**<mark style="color:red;">**segment**</mark>**&#x20;for&#x20;**<mark style="color:blue;">**Brand X**</mark>

This shows the share of each segment's sales for Brand X (same as the percentage of dollar sales in XYZ, and adds up to 100%)

<figure><img src="https://977923713-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJHwf1QFuv1BRPzfSnL2Z%2Fuploads%2Fq1tF1t0U9RyVBs4l02GE%2Fimage.png?alt=media&#x26;token=d6ad715d-8a8b-4a53-ae5a-6150fcd64fac" alt="" width="375"><figcaption></figcaption></figure>

#### **Marketshare&#x20;**<mark style="color:green;">**dollar sales**</mark>**&#x20;for&#x20;**<mark style="color:red;">**Brand X**</mark>**&#x20;in 2021 compared to 2022**

<figure><img src="https://977923713-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJHwf1QFuv1BRPzfSnL2Z%2Fuploads%2FES0K7Sbiscyhy8s3koIz%2Fimage.png?alt=media&#x26;token=5299ccf3-60c8-4347-b54f-14a427008b4d" alt="" width="563"><figcaption></figcaption></figure>

### **Change in marketshare**

"Change in market share" refers to the variation in the percentage of a company's sales (or another relevant measure) within a specific market or industry over a given time period. This change can be due to factors such as new product launches, pricing strategies, marketing efforts, or changes in consumer behavior. Understanding the "change in market share" helps businesses evaluate the effectiveness of their strategies, monitor competition, and identify market trends.

Now, from 4.2 version, users can now include "**change in market share"** keyword for marketshare-related queries. With this out-of-the-box support for "change in market share" keyword, users can now better analyze changes in market share over time or across different conditions, empowering their decision-making process.

<figure><img src="https://files.helpdocs.io/6dnnwn52e3/articles/jcg3qbkz5y/1685972503317/ezgif-com-video-to-gif-8.gif" alt=""><figcaption></figcaption></figure>

It's important to understand that the placement of the target variable in the query can significantly affect the resulting data. For instance, the two queries below provide different outputs due to the change in position of 'Advil', the target variable:

* `market share of dollar sales for Advil by segment`
* `market share of dollar sales by segment for Advil`

When adding a filter for the target variable and breaking it down by another filter, a new type of query arises. For example, `market share of dollar sales for Advil for adult internals for retailers` . To compare these results over different time periods, such as the "last 4 weeks vs the same period a year ago", we've introduced support for "**change in market share**" keyword queries.

#### **Syntax for change in market share**

To utilize this feature, ensure you provide the following values in the query where the target variable appears after the measure column. The syntaxes are,

* **Standard Syntax**: Show me \[change/percentage change/percent change] in market share <mark style="color:green;">**\<M1>**</mark> for <mark style="color:red;">**\<V1>**</mark> for <mark style="color:blue;">**\<F1>**</mark> \[vs/ compared to] <mark style="color:blue;">**\<F2>**</mark>
* **Syntax with Global Filters**: Show me \[change/percentage change/percent change] in market share <mark style="color:green;">**\<M1>**</mark> for <mark style="color:red;">**\<V1>**</mark> for <mark style="color:blue;">**\<F1>**</mark> \[vs/ compared to] <mark style="color:blue;">**\<F2>**</mark> for X1 for X2

Here,

* <mark style="color:green;">**M1**</mark> represents the measure
* <mark style="color:red;">**V1**</mark> represents the target variables
* <mark style="color:blue;">**F1**</mark> and <mark style="color:blue;">**F2**</mark> represent a list of filters for the target population, with multiple filters following "for" or "in"
* **X1** and **X2** represent a list of global filters, including dimension or date columns

Users can now execute queries such as:

* Show me \[change/percentage change/percent change] in market share <mark style="color:green;">**Sales**</mark> for <mark style="color:red;">**Nike**</mark> for <mark style="color:blue;">**New York**</mark> vs <mark style="color:blue;">**California**</mark>
* Show me \[change/percentage change/percent change] in market share <mark style="color:green;">**Sales**</mark> for <mark style="color:red;">**GoPro**</mark> for <mark style="color:blue;">**North America**</mark> vs <mark style="color:blue;">**South America**</mark> for 2022
* Show me \[change/percentage change/percent change] in market share <mark style="color:green;">**Sales**</mark> for <mark style="color:red;">**Nike**</mark> for <mark style="color:blue;">**New York**</mark> vs <mark style="color:blue;">**California**</mark> for 2022 for First-class shipping

{% hint style="info" %}
From v4.3, users can assess the percentage change in market share without specifying a target filter.
{% endhint %}

### **Syntax and examples of queries that can be executed**

Here \<filter 1> and \<filter 2> represent dimensions or time periods

**Syntax 1:** Show me change/percentage change in marketshare \<measure> by \<dimension> for/in \<filter 1> compared to/vs. \<filter 2>

<mark style="color:orange;">**Example 1:**</mark> <mark style="color:orange;"></mark><mark style="color:orange;">Show me change/percentage change in marketshare sales by category for/in California compared to/vs. Washington</mark>&#x20;

**Syntax 2:** Show me change/percentage change in marketshare \<measure> by \<dimension> for/in \<filter 1> compared to/vs. \<filter 2>

<mark style="color:orange;">**Example 2:**</mark> <mark style="color:orange;"></mark><mark style="color:orange;">Show me change/percentage change in marketshare sales by category for/in 2013 compared to 2014</mark>

**Syntax 3:** Show me change/percentage change in marketshare \<measure> for/in \<filter 1> compared to/vs. \<filter 2>

<mark style="color:orange;">**Example 3:**</mark> <mark style="color:orange;"></mark><mark style="color:orange;">Show me change/percentage change in marketshare sales for/in California compared to/vs. Washington</mark>&#x20;

<br>
