Audiences with Array of Objects | Community
Skip to main content
Level 3
May 22, 2025
Solved

Audiences with Array of Objects

  • May 22, 2025
  • 2 replies
  • 1041 views

Hi,

I’m working with a schema that contains an array of objects — for example:
accounts: [{ account_number, account_type, account_status }]

I’d like to create an audience that qualifies a user only if there is at least one object in the accounts array where:

  • account_type = "savings"

  • account_status = "active"

The key requirement is that both conditions must be true within the same object, not across multiple objects in the array.

 

Example scenario:
Given this user data:
accounts: [
{ account_number: "123", account_type: "savings", account_status: "inactive" },
{ account_number: "456", account_type: "checking", account_status: "active" }
]

 

The user should not qualify, as the savings account_type is in one object and account_status = active is in another object.

 

Any guidance on how to set this up in the audience builder would be appreciated!

 

Thanks!

Best answer by AnkitJasani29

Hi @trojan_horse ,

In the Segment Builder UI itself you cannot pick “accounts[1].account_type” (or any arbitrary zero-based index). The UI treats arrays as unordered collections and only gives you the built-in quantifier functions (exists/includes/count, etc.), so there’s no “pick element at position N” control in the drag-and-drop canvas.
If you really need position‐based access you have to flip into Code View (the PQL editor) and use the little “first-item” helper that PQL exposes:

accounts.head().account_type = "savings"

Reference: https://experienceleague.adobe.com/en/docs/experience-platform/segmentation/pql/array-functions

UI (drag-and-drop): no direct index access

Code View (PQL): use accounts.head().field for the first element; beyond that, you’d need to move into a post-ingest SQL/Query Service solution for arbitrary positions.

Note: This response is inspired from Generative AI.

 

Thanks,

Ankit

2 replies

Parvesh_Parmar
Community Advisor
Community Advisor
May 22, 2025

Hi @trojan_horse , 

As far as I know, this specific use case — where multiple conditions must be met within the same object of an array — is not currently supported directly in Adobe Experience Platform’s Audience Builder.

 

Because of this limitation, it’s important to carefully consider how data is modeled and how it will be used for segmentation before designing the schema.

 

If you know there will only be a limited number of account objects (for example, a maximum of three), you can define the audience condition using positional array indexing like this:

 

(accounts[0].account_type == "savings" AND accounts[0].account_status == "active")
OR
(accounts[1].account_type == "savings" AND accounts[1].account_status == "active")
OR
(accounts[2].account_type == "savings" AND accounts[2].account_status == "active")

 

This approach isn’t ideal, but it can work if the number of possible array entries is small and fixed.

 

Hope this helps!

 

Kind regards,

Parvesh

 

Parvesh Parmar – Adobe Community Advisor https://www.linkedin.com/in/parvesh-parmar/
Level 3
May 22, 2025

Thanks Parvesh. 

 

Question, how exactly can we refer to an index of the array from audiences, using the audience builder?

AnkitJasani29
AnkitJasani29Accepted solution
Level 6
May 23, 2025

Hi @trojan_horse ,

In the Segment Builder UI itself you cannot pick “accounts[1].account_type” (or any arbitrary zero-based index). The UI treats arrays as unordered collections and only gives you the built-in quantifier functions (exists/includes/count, etc.), so there’s no “pick element at position N” control in the drag-and-drop canvas.
If you really need position‐based access you have to flip into Code View (the PQL editor) and use the little “first-item” helper that PQL exposes:

accounts.head().account_type = "savings"

Reference: https://experienceleague.adobe.com/en/docs/experience-platform/segmentation/pql/array-functions

UI (drag-and-drop): no direct index access

Code View (PQL): use accounts.head().field for the first element; beyond that, you’d need to move into a post-ingest SQL/Query Service solution for arbitrary positions.

Note: This response is inspired from Generative AI.

 

Thanks,

Ankit

Adobe Employee
May 27, 2025

Hi @trojan_horse ,

 

I would recommend reviewing the response to similar question posed here. This is possible.

 

 

  • When you drag an item from the left rail that is in an array, it makes a "variable" container.
  • This container looks different from other, simple containers in that it shows a "variable pill".
  • This variable represents a single item from the array. If you want a single item to match multiple criteria, you place all rules inside that same single variable container.