[n8n] Calcul difference amount on a specific field

Hello everyone,

I am a beginner in n8n. I am reaching out to you because I need your help with performing a calculation in the workflow below. I am stuck at the last two nodes: “summarize” and “result.”

For the “Summarize” node, I need to apply the following business rule (for the “cust1” case):

If the amount in the “SubRed_Amount” field corresponding to “SOD” in the “TypeOpe” field is greater than the “ROD” amount, then calculate and display the difference (409000) in the “subRed_Amount” field and indicate “SOD” in the “TypeOpe” field (ultimately resulting in only one line).
If the amount in the “SubRed_Amount” field corresponding to “ROD” in the “TypeOpe” field is greater than the “ROD” amount, then calculate and display the difference (409000) in the “subRed_Amount” field and indicate “SOD” in the “TypeOpe” field (ultimately resulting in only one line).
I hope the description of the issue I am facing is clear and explicit enough.

Thank you in advance for your assistance.

Best regards.

Nodes on canvas :

Ouput returned on “Summarize” node :
i would like just 1 line for cust1 (SOD or ROD with the calculated amount on the ad’hoc field)

Information on your n8n setup

  • n8n version: 1.36.1
  • Database : SQLite
  • EXECUTIONS_PROCESS setting : by default
  • Running n8n via : Docker
  • Operating system: windows 11

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:

Can you provide an example output of Extract from file node?

Hi barn4k,

you will find hereafter an example output for the node summarize :

[
{
“Name”: “cust1”,
“CCY”: “USD”,
“appended_CCY”: [
“USD”,
“USD”
],
“appended_TypeOpe”: [
“SOD”,
“ROD”
],
“appended_$json’code_Name’”: [
“XXXXH34”,
“XXXXH34”
],
“appended_$json’SubRed_Amount’”: [
221000,
630000
],
“appended_$json’date_NAV’”: [
“20240318”,
“20240318”
]
},
{
“Name”: “cust1”,
“CCY”: “JPY”,
“appended_CCY”: [
“JPY”
],
“appended_TypeOpe”: [
“SOD”
],
“appended_$json’code_Name’”: [
“XXXXH34”
],
“appended_$json’SubRed_Amount’”: [
1310000
],
“appended_$json’date_NAV’”: [
“20240317”
]
},
{
“Name”: “cust2”,
“CCY”: “USD”,
“appended_CCY”: [
“USD”
],
“appended_TypeOpe”: [
“ROD”
],
“appended_$json’code_Name’”: [
“YYYB12”
],
“appended_$json’SubRed_Amount’”: [
135000
],
“appended_$json’date_NAV’”: [
“20240318”
]
},
{
“Name”: “cust2”,
“CCY”: “JPY”,
“appended_CCY”: [
“JPY”
],
“appended_TypeOpe”: [
“SOD”
],
“appended_$json’code_Name’”: [
“YYYB12”
],
“appended_$json’SubRed_Amount’”: [
1230000
],
“appended_$json’date_NAV’”: [
“20240318”
]
}
]

Thank you for your help

Best regards

Seb

if anybody could help me…
Best regards