What is wrong in this formula CASE WHEN {purchaseo...
# ask-stanley-ai
n
What is wrong in this formula CASE WHEN {purchaseorder.amountremaining}/{purchaseorder.amount} < 0.10 THEN 'Yes' ELSE 'No' END
c
AI generated answer (using internal Slack threads):
The formula
CASE WHEN {purchaseorder.amountdue}/{purchaseorder.amount} < 0.10 THEN 'Yes' ELSE 'No' END
seems to be checking if the ratio of the amount due to the total amount of a purchase order is less than 0.10. If it is, it returns 'Yes', otherwise it returns 'No'. There are a few potential issues with this formula: 1. Division by Zero: If the
{purchaseorder.amount}
is zero, this formula will result in a division by zero error. To avoid this, you can use the
NULLIF
function to replace zero with NULL in the denominator. The revised formula would be:
CASE WHEN {purchaseorder.amountdue}/NULLIF({purchaseorder.amount}, 0) < 0.10 THEN 'Yes' ELSE 'No' END
. 2. Data Type Mismatch: Ensure that both
{purchaseorder.amountdue}
and
{purchaseorder.amount}
are numeric fields. If they are not, you may need to convert them to numeric data types before performing the division. 3. HTML Entities: The formula uses HTML entities for the less than symbol (
<
). If you're writing this formula in a context that doesn't interpret HTML entities, you should replace
<
with
<
. Please check these points and adjust your formula accordingly. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840441644
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83154422
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829218149
Please provide your feedback on this answer.