Skip to main content
Elise S. 님이 #Reports & Dashboards에 질문했습니다

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일 오후 5: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