> ## Documentation Index
> Fetch the complete documentation index at: https://docs2.zenskar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Two-dimensional tiered pricing

**Two-dimensional or 2D tiered pricing** is a pricing strategy where the cost of a service or product is set at different tiers, or levels, based on two dimensions, or factors.

## Difference between 2D tiered pricing model and tiered pricing model

2D tiered pricing model is similar to [tiered pricing model](https://dash.readme.com/project/zenskar/v1.2/refs/tiered-pricing). The most important difference being that the tiered pricing model has tiers based on one factor whereas the 2D tiered pricing model has tiers based on two factors.

In the following example for the tiered pricing model, commission tiers are defined for the service or product based on a single factor: quantity.

| Number of units of the service or product | Commission charged per unit (USD) |
| :---------------------------------------- | :-------------------------------- |
| 1-99                                      | 0.01                              |
| 100-200                                   | 0.005                             |
| 201-∞                                     | 0.002                             |

In the following example for the 2D tiered pricing model, commission tiers have been defined for the service or product based on two factors:

* quantity
* per-unit price range

| Number of units of the service or product | Commission (USD per unit) when per unit costs \$0–100 | Commission (USD per unit) when per unit costs more than \$100 |
| :---------------------------------------- | :---------------------------------------------------- | :------------------------------------------------------------ |
| 0–50000                                   | 0.01                                                  | 0.02                                                          |
| 50000–100000                              | 0.005                                                 | 0.01                                                          |
| 100000–150000                             | 0.002                                                 | 0.005                                                         |
| 150000-∞                                  | 0.001                                                 | 0.002                                                         |

<Image alt="Fig.2: In a product based on 2D tiered pricing, the y-axis represents the quantity of VMs sold, whereas the x-axis represents the zone in which the VM runs. The US zone is represented 1 in the product, whereas the Europe zone is represented by 2 in the product." align="center" src="https://files.readme.io/c4765c1-Drawing_2024-07-25_10.25.34.excalidraw.png">
  Fig.1: In this product based on the 2D-tiered pricing model, the y-axis can be thought of as representing the quantity, whereas the x-axis can be thought of as representing the per-unit price range. The commission rate is fixed based on values of both the x-axis and the y-axis.
</Image>

## How to add a product based on 2D tiered pricing in Zenskar

> 🔖 Important
>
> Refer the [products documentation](https://zenskar.readme.io/reference/products) to learn more about the concept of products in Zenskar.

### Step 1: Create a product based on 2D tiered pricing

1. Navigate to **Contracts** > **Products**, and click on the **ADD PRODUCT** button.
2. Select the **2D Tiered Pricing** from the drop-down.
3. Select or deselect **Metered**:
   1. If the service or product is [metered](https://zenskar.readme.io/reference/metering), select the [appropriate usage aggregate](https://zenskar.readme.io/reference/usage-aggregates) from the drop-down. The usage aggregates for 2D tiered pricing model must be created in the [SQL query builder](https://zenskar.readme.io/reference/usage-aggregates#sql-builder). [Visual query builder ](https://zenskar.readme.io/reference/usage-aggregates#add-an-aggregate-using-the-visual-builder) cannot be used.
   2. If the service or product is not metered, enter the quantity.
4. Fill in all other details, and select all the desired features.
5. Save the product.

### Example: metered product

> 🔖 Note
>
> This pricing model is available only for metered products.

* Let us assume that you sell provide a platform for sellers, and you charge commission on sales made by the sellers.
* Commission tiers have been defined based on two factors:
  * quantity
  * per-unit price range

| Number of units of the service or product | Commission (USD per unit) when per unit costs \$0–100 | Commission (USD per unit) when per unit costs more than \$100 |
| :---------------------------------------- | :---------------------------------------------------- | :------------------------------------------------------------ |
| 0–50000                                   | 0.01                                                  | 0.02                                                          |
| 50000–100000                              | 0.005                                                 | 0.01                                                          |
| 100000–150000                             | 0.002                                                 | 0.005                                                         |
| 150000-∞                                  | 0.001                                                 | 0.002                                                         |

* Owing to the nature of consumption, this is a metered product.
* The usage aggregate named **demoAggregate** is being used to fetch usage details for a given billing period.

<Image alt="Fig. 1: A product based on 2D tiered pricing model: the y-axis is the quantity of VMs sold, whereas the x-axis is the zone in which the VM runs. The US zone is represented by 1" align="center" width="75% " border={true} src="https://files.readme.io/de5ff87-Screenshot_from_2024-07-25_10-18-24.png">
  Fig. 1: A metered product based on 2D tiered pricing model.
</Image>

## Creating usage aggregates for 2D tiered pricing model

The usage aggregates for 2D tiered pricing model must be created in the [SQL query builder](https://zenskar.readme.io/reference/usage-aggregates#sql-builder) due to the complexity of the pricing model. [Visual query builder ](https://zenskar.readme.io/reference/usage-aggregates#add-an-aggregate-using-the-visual-builder) cannot be used.

> 👷 Engineering effort required
>
> Creating raw SQL queries for complex scenarios is the job of an engineer proficient in SQL.
