Best answer

Filter by Zapier by Comparing Two Variables

  • 13 December 2019
  • 11 replies
  • 1877 views

Userlevel 5
Badge +1

So I am setting up a Zap that needs to compare the Invitee Name and Cancelation Name when someone cancels an event in Calendly. The use case is to ensure that the Zap only runs when the original invitee cancels the event and not an optional attendee.

The way I first went about handling this, was going to be to simply compare the two variables in a filter step. Ideally, this would have gone:

Continue if:

<Invitee Name> <- Exactly Matches -> <Cancelation Name>

However, you can only use a variable in the first field, and then have the second field hard coded.

I'm working out a workaround for this, essentially where the logic is done in a different step (will update with solution if found), and then the output of that step is used in the filter.

In any case I'd like to also submit this as a feature request to Zapier :D


icon

Best answer by Danvers 17 December 2019, 11:37

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.

11 replies

Userlevel 1

I typically use a Spreadsheet-like formula step and then a filter in these situations, my formula would look something like if("" = "", true, false) then run a filter on the results of that step using boolean is true.

 

One caveat here: spreadsheet-like formulas are for numbers only, however you can use strings if you put quotes around the strings, thus the quotes in my formula above.

 

So I actually tried this before googling how to do it and landing here and saw that you said this way works, so I went back and tried it again and I have confirmed it absolutely does not work.  Maybe it used to work but it definitely doesn’t work anymore :(

OK I’ve figured out how to make this work now but it’s needed a little tweaking from the original suggestion, this is how your if statement should look if you want it to work: if("" = "", “true”, “false”)

Userlevel 1

I typically use a Spreadsheet-like formula step and then a filter in these situations, my formula would look something like if("" = "", true, false) then run a filter on the results of that step using boolean is true.

 

One caveat here: spreadsheet-like formulas are for numbers only, however you can use strings if you put quotes around the strings, thus the quotes in my formula above.

 

So I actually tried this before googling how to do it and landing here and saw that you said this way works, so I went back and tried it again and I have confirmed it absolutely does not work.  Maybe it used to work but it definitely doesn’t work anymore :(

Userlevel 4
Badge +2

:heart_eyes: related topics in this forum! I just posted about this very topic and thanks to the Related Topics function, I discovered this thread. And now I think I can continue my efforts with my planned Zap so thank you all for these suggestions.

Userlevel 7
Badge +12

@dzisner's workaround should work here. The first thing to say is that the Zap editor wont turn that text into the actual value from the previous step, it’ll look like {{73307026__variablename}}

If you've tried it and the filter doesn't work, make sure that the text for the variable is correct by doing the following:

  1. Open another step (after the one with the variable that you need to use)
  2. Use the editor to add the variable in the way that you usually would
  3. Highlight the variable and press ctrl/command + c to copy it
  4. Go to your filter step and paste it into the last box

I hope that helps, let us know how you get on!

 

Userlevel 5
Badge +1

@dzisner I tried that but it didn't seem to work. I think that Zapier is reading the variable as literal text, not as what it represents. If you got this to work though, I'd love to hear more about it as it could solve a lot of situations!


Userlevel 1

Hi guys,

You can actually compare two variables in a filter, vs. comparing a variable with a fixed value.

On the left side of the filter, select the variable.

On the right side enter the variable's full syntax - like so:

{{73307026__output}}


You can pull this syntax from a later step by selecting the field, marking and copying it then pasting it in the right side of the filter.

We use this to compare current and previous values returned by a pipedrive webhook and it works like butter.



Userlevel 7
Badge +10

What's great about Zapier at this point is it's so well developed there are often a few different ways to solve a problem. 😅


Userlevel 7
Badge +10

Yeah @BlakeBailey I'm on that side too, if I can do it without code so my teammates/clients can understand it and diagnose/troubleshoot it better then I'm going to do it without code... However, @AndrewJDavison_Luhhu's solution is probably more legit from an accuracy standpoint... the double == and the triple === in code makes sure things are exactly the same, however for my needs the spreadsheet style formula works 99% of the time.


Userlevel 5
Badge +1

Awesome thanks @Paul and @anand! I had a feeling that this might have been asked before but wasn't sure.

Ironically, I was off trying both of these things on my own before I came back and read these suggestions.

I decided to go with the Spreadsheet style formula (which I didn't know about the quotation hack!), since it's easier for others to pick apart.

Thanks again!


Userlevel 7
Badge +10

I typically use a Spreadsheet-like formula step and then a filter in these situations, my formula would look something like if("" = "", true, false) then run a filter on the results of that step using boolean is true.


One caveat here: spreadsheet-like formulas are for numbers only, however you can use strings if you put quotes around the strings, thus the quotes in my formula above.


Userlevel 7
Badge +10

@BlakeBailey - I second this. In fact, this has been discussed before on here - I think the conclusion from @Danvers was that there was a technical reason which made it more difficult to add than it seems.

Meanwhile, you can get this done with a code step

var compareA = inputData.A;

var compareB = inputData.B;

if (compareA == compareB) {

return {outcome: 'same'};

}

else {

return {outcome: 'different'};

}

You can then add a filter step to continue only on 'outcome=same'.