How to use jmespath to return value depending on other value

Describe the problem/error/question

I’m using an http request to pull information from the budgeting tool that I use (Lunch Money). I want to return a table of objects with the field name as the column header and the to_base value (account balance) as the row value.

EDIT: I want to return the to_base value based on the id value. This will make the automation more robust because the number of accounts in the array can change occasionally, as happened recently when I closed an account.

So it would look like:

What is the error message (if any)?

I’ve tried several permutations. When n8n thinks my syntax is correct I get a null response.

Please share your workflow

Share the output returned by the last node

[
  {
    "mortgage": 0,
    "savings": 0,
    "checking": 0
  }
]

Information on your n8n setup

  • n8n version: 1.86.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: Unraid

Hey @peckish Change your expression to {{ $jmespath($json.plaid_accounts, "[?id == `11111`].to_base" ) }}

3 Likes

Thank you so much, @Ruslan_Yanyshyn! That works. I knew it was a syntax problem but I thought I had tried every permutation. Obviously I missed that one.

Hi @peckish ! Glad to assist. Syntax errors are among the most frequent programming mistakes. :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.