# How to Resolve Formula Collision and Work with Cells in SAP BW/4HANA

SAP BW/4HANA is a powerful data warehousing solution that enables you to create, analyze and report on key performance indicators (KPIs) for your business. One of the features of SAP BW/4HANA is the ability to define formulas and cells, which are expressions that can be used to calculate or manipulate key figures. Formulas and cells can help you perform complex calculations, comparisons and conditional logic on your data.

However, sometimes you may encounter a situation where two formulas or cells conflict with each other. For example, you may have two structures that both contain formulas, and it is unclear to the system how to calculate the formulas at the point where they intersect. This is called a formula collision. Formula collision can lead to incorrect or inconsistent results in your query.

In this blog post, we will show you how to resolve formula collision and work with cells in SAP BW/4HANA. We will explain what formula collision is, how it works, and how to use different settings and options to avoid or handle it. We will also provide some examples of formulas and cells in different scenarios.

## What is Formula Collision in SAP BW/4HANA?

Formula collision is a type of conflict that occurs when two formulas or cells intersect in a query. It happens when the system does not know which formula or cell to apply last, as this can affect the final result.

For example, suppose you have a query that has two structures: one with a formula that calculates the profit margin as `(Profit / Revenue) * 100`

, and another with a formula that calculates the revenue growth rate as `(Revenue - Previous Period Revenue) / Previous Period Revenue * 100`

. If you run the query, you will see something like this:

Product Category | Profit Margin | Revenue Growth Rate |
---|---|---|

A | 20% | 10% |

B | 15% | 5% |

C | 25% | 15% |

Total | ? | ? |

The question marks indicate that there is a formula collision at the total row. The system does not know whether to calculate the profit margin first and then the revenue growth rate, or vice versa. Depending on the order of calculation, the result can be different.

To resolve formula collision, you need to specify which formula or cell to apply last in case of conflict. You can do this by using the Eliminate Formula Collision setting in the Formula Editor or Cell Editor window.

## How to Use Eliminate Formula Collision Setting in SAP BW/4HANA?

The Eliminate Formula Collision setting allows you to define how to handle formula collision for a formula or cell in SAP BW/4HANA. You can access this setting by opening the Formula Editor or Cell Editor window and going to the Aggregation tab.

The Eliminate Formula Collision setting has four options:

- Use Result of This Formula: This option means that the formula or cell will be applied last in case of conflict. This will override any competing formula or cell.
- Use Result of Competing Formula: This option means that the formula or cell will be applied first in case of conflict. This will allow any competing formula or cell to override it.
- Use Default: This option means that the system will use the default behavior for resolving formula collision. The default behavior depends on the type of aggregation used for the formula or cell. For example, if the aggregation is SUM, then the system will apply the formula or cell last. If the aggregation is AVG, then the system will apply the formula or cell first.
- Use Key Figure Definition: This option means that the system will use the definition of the key figure used in the formula or cell for resolving formula collision. The definition of the key figure can be found in transaction RSD1.

You can choose any of these options depending on your desired outcome and logic. However, you should be careful when using this setting, as it can affect other formulas or cells in your query.

## How to Work with Cells in SAP BW/4HANA?

Cells are another way of defining expressions that can be used to calculate or manipulate key figures in SAP BW/4HANA. Cells are similar to formulas, but they have some additional features and options.

Cells allow you to:

- Define expressions based on conditions and exceptions
- Define expressions based on reference characteristics
- Define expressions based on restricted key figures
- Define expressions based on calculated key figures
- Define expressions based on variables
- Define expressions based on text elements
- Define expressions based on hierarchies
- Define expressions based on time-dependent attributes

To create cells in SAP BW/4HANA, you need to follow these steps:

- Open the BEx Query Designer tool and create a new query or open an existing one.
- In the Rows or Columns panel, right-click on Key Figures and select New Cell.
- In the Cell Editor window, enter a name and description for your cell.
- In the Definition tab, enter your expression using existing key figures, restricted key figures, calculated key figures, variables, text elements, hierarchies or time-dependent attributes as operands. You can use parentheses to group expressions and change the order of operations. You can also use conditions and exceptions to define specific scenarios for your expression.
- In the Aggregation tab, select the aggregation method and the Eliminate Formula Collision setting for your cell.
- In the Reference Characteristic tab, select the reference characteristic or dimension that you want to use for grouping the data before applying the aggregation method for your cell.
- Click on Check to validate your cell and click on OK to save it.
- Drag and drop your cell from Key Figures to Rows or Columns as desired.
- Save and execute your query to see the results of your cell.

## Examples of Formulas and Cells in SAP BW/4HANA

Here are some examples of formulas and cells in SAP BW/4HANA:

- Profit Margin with Exception Aggregation: This formula calculates the profit margin as
`(Profit / Revenue) * 100`

with exception aggregation AVG of All Values <> 0 [AV0] and reference characteristic Product Category. This means that the system will calculate the average profit margin for each product category excluding zero values, and then calculate the total profit margin based on the averages. - Revenue Growth Rate with Condition: This cell calculates the revenue growth rate as
`(Revenue - Previous Period Revenue) / Previous Period Revenue * 100`

with condition Revenue > 0. This means that the system will only calculate the revenue growth rate for records where revenue is positive, and ignore records where revenue is zero or negative. - Profit Variance with Exception: This cell calculates the profit variance as
`(Profit - Plan Profit) / Plan Profit * 100`

with exception Plan Profit = 0. This means that the system will only calculate the profit variance for records where plan profit is not zero, and return a special value NOP (no operation) for records where plan profit is zero.

## Conclusion

In this blog post, we have learned how to resolve formula collision and work with cells in SAP BW/4HANA. Formula collision is a type of conflict that occurs when two formulas or cells intersect in a query. Formula collision can be resolved by using the Eliminate Formula Collision setting in the Formula Editor or Cell Editor window. Cells are another way of defining expressions that can be used to calculate or manipulate key figures in SAP BW/4HANA. Cells have some additional features and options that allow you to define expressions based on conditions, exceptions, reference characteristics and other elements.

We hope you found this blog post helpful and informative. If you have any questions or feedback, please leave a comment below.

Disclaimer: This content is generated by AI.