Clay Icon

Using Ternary Operator in Merge Column with Fallback Value: How to Get Clay to Evaluate Next Column

·
·

I’d like to use a ternary operator inside a merge column, like in the attached example. If the conditional expression is false, then I’d like Clay to move on to evaluate the following column. I’ve tried passing in '' (as in the attached screenshot), false , null, and undefined as the fallback value to get Clay to move on to the next column, but it won’t. Is there a value I can replace '' in the screenshot with in order to get Clay to move on to evaluating the next column?

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    Hey hey! Can you drop the URL for your table here? (if applicable) 🫶 Don't worry, only admins will be able to open your table 😉

  • Avatar of Joe R.
    Joe R.
    ·
    ·

    I’ve found a less elegant workaround for it so no table, but would like to know for future reference

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    Hey Joe! To merge with a more complex logic like this, I usually recommend just using a standard formula column to write the logic in one single go. Can totally see why this would help because you're breaking it down into sections, but I think it should also work here if given the command

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    so instead of ending with: ​​​​­​​: ''​ I would write it like this -> ​​ ​­ ​​­ ​: (If X=1 ? Y : ...)​​​​​​

  • Avatar of Joe R.
    Joe R.
    ·
    ·

    Thanks Arturo - to clarify, are you saying use : … instead of : ''

  • Avatar of Joe R.
    Joe R.
    ·
    ·

    like an ellipsis?

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    Ohh, sorry, not the ellipsis itself but to reference continuation of the formula to address the following logic until you reach the final output, ending the entire formula in ​: ''

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    A proper example of the logic:{{col1}} ? {{x}} : ({{col2}} = 1 ? {{y}} : (!{{col3}} ? {{z}} :''))

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    basically a bunch of "if -> then" statements nested in a single argument until the end is closed with "empty"

  • Avatar of Joe R.
    Joe R.
    ·
    ·

    Right yeah, I’ve been doing nested ternaries, but to clarify, my question here in more generalized terms is… What is the fallback value I need to put in for a Merge column in Clay in order for Clay to move on to the next column? What is the backend logic Clay uses to move from one column to the next in a Merged column and can it be replicated by a user by using a formula?

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    Well, based on how our email waterfalls are set up, it should work because it resembles this

    b22aa9cf-66b9-4c01-a820-36af7d2125d0.png(52 kB)
  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    So, curious if you may have a space in any of those columns that would consider it a character and hard to catch, thus not checking the next column?

  • Avatar of Joe R.
    Joe R.
    ·
    ·

    Hmm

  • Avatar of Joe R.
    Joe R.
    ·
    ·

    I don’t think so. I tried inserting a random string inside the '' like this 'test' and the column value would switch to 'test'

  • Avatar of Joe R.
    Joe R.
    ·
    ·

    But that’s a good point about your waterfall setup. I’ll try it again knowing that a blank string should move the execution to the following column

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    Yep! Let me know if you need an extra eye to spot any potential issues here. The only other thing that comes to mind is stale data, something not running yet, and why it's on "standby" until everything has run for it to evaluate.

  • Avatar of Joe R.
    Joe R.
    ·
    ·

    Thanks Arturo - should’ve kept the column instead of changing the logic so we could look at it together. I’ll keep that in mind for next time

  • Avatar of Clay T.
    Clay T.
    APP
    ·
    ·

    No worries! will keep an eye out if you ever run into this again :D