Retrieving Items from previous nodes

Hey guys.

I’m trying to get the average of x Items, then us the if node to compare if each item is greater than 5x the total average.

Here is the current workflow

this doesn’t work because the summarize node only outputs the average as 1 item, I also need the 20 items from the split out node to compare them to the average.

Using the merge node to append the items and to output 21 items doesn’t work, gives null for the calculated average.

and using this in the code node gives the following error.


tldr: Summarize node outputs 1 item, I want it to output 21 items so that I can compare them to each other usisng the IF node.

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hi @Trash :wave:

Could you let us know what version of n8n you’re running and how you’re running it? Could you also share some sample data (obviously nothing sensitive!) that you’re getting from Baserow that we could use to test, and also share your workflow? You should be able to copy and paste the nodes from n8n by hitting ctrl/cmd + a and then ctrl/cmd + c, and pasting the json data over here in a code block. :+1: That really helps us look into things more!

1 Like

Im running the latest version of n8n on cloudron. Unfortunately I cant share the data but I dont think that matters here. Ive seen here

that this function

const allItems = $items("Filter Tasks");

should output all the items in the split out node but it returns this error instead

ERROR: Code doesn't return an object [item 0]
Please return an object representing the output item. ('undefined' was returned instead.)

Hi @Trash :wave: We only ask for sample data to make it a little easier to reproduce the issue :sweat_smile: You could do something like return allItems = $('Filter Tasks').all(), as the syntax has changed after version 1 :+1:

Something similar to this should work:

No need for the Code node, is all I’m trying to show :slight_smile: But if you would prefer to use it, there’s an example that does something similar to what you’re doing (I think) above!

4 Likes

Thank you so much. the code snippet you provided worked. I tried using the merge node before but it didn’t work.

2 Likes

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