Best answer

Zapier Formatter for spreadsheet-style formula is not working

  • 25 November 2022
  • 5 replies
  • 100 views

I am losing my mind a bit with this one and I am hoping someone can help!

I am using a spreadsheet-style formula with an ‘IF’ statement to get my output.

What I am trying to write is: If the discount % value is null, then put the discount value, otherwise, take discount % divide it by 100 and multiply it by price).

 

The part I am having trouble with is the multiple it by price. For some reason, if the discount % value is null, it is taking the discount value and multiplying that by price?? I have tried so many different variations of this I cannot figure out why this is happening:

 

Here is my statement:
IF(“Discount Percentage”=””,Discount,Discount Percentage/100*Price)

I have also tried putting brackets around the false statement component to ensure Discount doesn’t get multiplied by price, alas, it still does!

IF(“Discount Percentage”=””,Discount,(Discount Percentage/100*Price))
 

icon

Best answer by Troy Tessalone 25 November 2022, 16:47

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Userlevel 7
Badge +14

Hi @abrow214 

Good question.

Please post detailed screenshots with how your Formatter step is configured in order for us to have full context, thanks.

Hi @Troy Tessalone here is a screenshot:

 

 

 

In this case, the output SHOULD be $5,000. However, the output ends up being 549750 (a result of zapier taking 5000 dividing it by 100 and multiplying it by 10995).

When I got to test it, it briefly shows it computing like this:
 

 

Userlevel 7
Badge +14

@abrow214 

Alternatively, you can use a Code step.

 

let DiscountValue = inputData.DiscountValue;
let DiscountPercent = inputData.DiscountPercent;
let Price = inputData.Price;

let Discount = DiscountValue;

if (DiscountPercent) {
Discount = (parseFloat(DiscountPercent)/100) * parseFloat(Price);
}

if (!DiscountPercent) {
DiscountPercent = "";
}

output = [{Discount, Price, DiscountPercent, DiscountValue}];

 

RESULTS w/ DiscountPercent

 

RESULTS w/o DiscountPercent

 

Userlevel 7
Badge +14

@abrow214 

From testing, it appears the spreadsheet style formula doesn’t like when there is no value before the / in the false condition.

 

 

Thank you so much @Troy Tessalone this was the only solution that worked!