Using lookup operations

How to use lookup operations in Plytix formulas, with real examples of when you'd use each one

Lookup operations let you retrieve or replace values based on a reference, either mapping a value to a different one using a dictionary, or pulling a specific item out of a list by its position. This article covers both lookup operations, plus common use cases combining them.

DLOOKUP

Similar to VLOOKUP in Excel, but requires a dictionary. Replaces a value with a corresponding value from that dictionary.

Syntax:

DLOOKUP(value, dictionary, [default])
  • value: the value to replace.
  • dictionary: a set of keys and their corresponding replacement values, enclosed in curly braces, e.g. {"key1": "value1", "key2": "value2"}.
  • default (optional): the value to return if no match is found in the dictionary.

Example:

$ATT.COLOR = "red"

DLOOKUP($ATT.COLOR, {"red": "rojo", "blue": "azul"}, "not defined")

Result: rojo

INDEX

Returns the element at a specified position within a list.

Syntax:

INDEX(list, index)
  • list: the list to retrieve the element from.
  • index: the position of the element you want, starting at 1 for the first item.

Example:

$ATT.LIST = ["Apple", "Banana", "Cherry", "Date"]

INDEX($ATT.LIST, 1)

Result: "Apple"

Indexing starts at 1, not 0. INDEX($ATT.LIST, 1) returns the first item in the list.

If the index exceeds the list’s size, INDEX returns an empty value rather than an error, for example, INDEX(["Apple", "Banana"], 5) returns empty, since the list only has 2 items. The same applies to using INDEX on an empty list.

Common Use Cases for Lookup Operations

Translating attribute values for different markets

Use DLOOKUP to translate a fixed set of values (like colors, sizes, or material names) into another language, without maintaining a separate translated attribute:

DLOOKUP($ATT.COLOR, {"Red": "Rojo", "Blue": "Azul", "Green": "Verde"}, $ATT.COLOR)

Using the original value as the default means untranslated values pass through unchanged instead of showing blank.

Mapping your categories to a marketplace’s required taxonomy

Many marketplaces (like Google Shopping) require product categories to match their own specific taxonomy, which rarely matches how you’ve organized categories internally. DLOOKUP lets you map your own category values to the required output, without renaming anything in your PIM:

DLOOKUP($ATT.CATEGORY, {"Outerwear": "Apparel & Accessories > Clothing > Outerwear", "Footwear": "Apparel & Accessories > Shoes"})

Featuring just the primary value from a Multiselect attribute

If a Multiselect attribute stores several tags in a meaningful order (like ["Everyday", "Formal", "Outdoor"] for a product’s use cases), use INDEX to pull out just the first, primary one for a title or summary, without showing the whole list:

INDEX($ATT.USE_CASES, 1)

Safely handling lists that might be short or empty

Since INDEX returns an empty value rather than an error when the index doesn’t exist, combine it with IFBLANK (see Logical operations) to provide a fallback when a product’s list is shorter than expected:

IFBLANK(INDEX($ATT.FEATURES, 3), "N/A")

DLOOKUP and INDEX solve different problems: DLOOKUP replaces a value based on what it is, INDEX retrieves a value based on where it sits in a list.

Frequently Asked Questions

It uses standard JSON-style syntax enclosed in curly braces with key-value pairs.

Example: {"red": "rojo", "blue": "azul"}

It starts from 1 (1-based indexing). For example, INDEX($ATT.LIST, 1) retrieves the first item in the list.

It returns an empty value rather than throwing an error. You can safely wrap the formula in IFBLANK to supply a fallback or default value.