Skip to main content

Situation:

Our organization is selling both products and services. 

This means the Opportunity Products are populated with both physical items and services. 

 

Goal: 

To automatically calculate the number of physical pallets of products in an opportunity. 

 

What’s been done so far:

A formula is successfully generating the number of pallets for physical items (see screenshot).

The roll-up summary also works successfully. 

 

We have to types of pallets with different quantity for each types. Hence why they need to be considered separately (NA size and EURO size). 

 

There are 3 possible Record Type Id for Products: Accessories (physical item), Litter (physical item), Transport (service).

 

Problem encountered:

When a “Transport” product is added to the Opportunity, the formula encounters a division by zero. 

 

Here is the formula in question:

 

IF (

PricebookEntry.Product2.RecordTypeId = "Accessories",

Quantity / PricebookEntry.Product2.Units_per_NA_pallets__c,

IF (

PricebookEntry.Product2.RecordTypeId = "Transport",

NULL,

IF (

ISPICKVAL( Opportunity.Pallet_Type__c, "EURO" ),

Quantity / PricebookEntry.Product2.Units_per_EURO_pallets__c,

Quantity / PricebookEntry.Product2.Units_per_NA_pallets__c

)

)

)

 

If any one could check the above code and let me know what needs to adjusted to avoid the zero division, it would be very appreciated!

 

Screenshots: 

Formula is working for physical products and roll-up summary is working correctly.

Division by zero error during roll-up summary using the value of a formula field

 

When a non-physical product is added (ex: Transport), there is a division by zero.

zero-error.PNG

 

Let me know should you need more details with the Products, etc!

 

Thanks in advance for your help!

Kind regards, 

8 个回答
  1. 2021年11月30日 17:54

    You could use a BLANKVALUE function like this

     

    IF(

    PricebookEntry.Product2.RecordTypeId = "Transport",

    NULL,

    IF(

    PricebookEntry.Product2.RecordTypeId = "Accessories",

    ( Quantity / BLANKVALUE( PricebookEntry.Product2.Units_per_NA_pallets__c, 1)),

    IF(

    ISPICKVAL( Opportunity.Pallet_Type__c, "EURO" ),

    ( Quantity / BLANKVALUE( PricebookEntry.Product2.Units_per_EURO_pallets__c , 1)),

    ( Quantity / BLANKVALUE( PricebookEntry.Product2.Units_per_NA_pallets__c , 1))

    )

    )

    )

0/9000