People are frequently asking me to explain the difference between the two functions IFBLANK and ISBLANK. It’s confusing for several reasons. Obviously, the names are nearly identical. Also, the most common use for ISBLANK is inside an IF function!
Here’s how I explain ISBLANK and IFBLANK – plus some tips on keeping them straight.
IFBLANK
Let’s start with IFBLANK. This function takes in two to eight inputs, and outputs the first one that isn’t blank. This is useful if you want to output an attribute that’s populated in most of your items but might be blank in some. Therefore, you’ll want to have one or more fallback values. The name “IFBLANK” was chosen because the rules (in English) that use it often look like this: “Output attr1; IF that’s BLANK, output attr2; IF that’s BLANK, output attr3,” etc.
A good example of an IFBLANK is on our Amazon template. There’s a field called Product ID, where you specify each item’s ID, which can be a UPC, an ISBN, an ASIN, etc. We often have sellers who have UPCs for most items and want to use that for the Product ID. For some items, though, the UPC is blank. For those items, sellers want to use the item’s ASIN for Product ID. In English, this rule would be: “Output the item’s UPC; if that’s blank, output the item’s ASIN.” In a business rule:
IFBLANK($itemupc,$itemasin)
ISBLANK
While IFBLANK directly outputs one of its inputs, ISBLANK outputs either true or false values. We call this a Boolean function. Of the various Boolean functions you can use, about half begin with “IS”: ISBLANK, ISINLIST, ISNUMERIC, ISZERO. That’s not an accident: This is what we in the software world call a naming convention. A function that begins with “IS” probably returns a true/false value. You can think of these functions as answering a true/false question: “IS this value BLANK?” “IS this value IN that LIST?”
One of the most common uses of ISBLANK that I see is in a rule to send a “Product ID Type” to Amazon. This has to be a text value, such as “UPC,” “ISBN,” “ASIN,” etc. The text value for each item’s product ID type has to match the Product ID you’re sending. As I mentioned above, some sellers use UPC, with ASIN as a fallback value if UPC is blank.
For items where the Product ID is a UPC, Product ID Type should be the actual text “UPC,” and for the other items, the text should be “ASIN.” The rule for this (in English) is: If the item’s UPC value is blank, output “ASIN.” Otherwise, output “UPC.” Or in a business rule:
IF(ISBLANK($itemupc),”ASIN”,”UPC”)
I had a colleague ask me to write that rule so many times, it was becoming the bane of my existence. So I had the rule printed on a baby sleeper and gave it to her as a baby shower gift. True story.
Which Is Which?
So you know the difference between the two functions, but how do you remember when to use each one? Our business rule validation will help you out, because ISBLANK allows only one input, while IFBLANK requires more than one.
But if you want a simple mnemonic device, here’s what I suggest. Remember that IFBLANK outputs the first non-blank input, and is used to define fallback values. So when you think “first” or “fallback,” think “F” and go with the function that has an “F” in its name: IFBLANK.
Blogpost by Anthony Alford, ChannelAdvisor Technical Lead, a.k.a. The Feed Doctor