$min() function with variabless

Describe the problem/error/question

I am getting two numbers from a previous node and need to send the smaller via HTTPS node. I am trying to use the function $min() with 2 arguments. When I try with 2 numbers, it works, but not with 2 variables:

{{ min(5,4) }} returns 4 as expected,


{{ $min( {{ $(‘Split In Batches’).item.json[“total_currency_balance”]}},{{ $(‘Split In Batches’).item.json[“currency_expiring”] }} ) }} returns invalid syntax

Any idea of what I am doing wrong?

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Information on your n8n setup

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

hi @fxholl
Double brackets inside other double brackets won’t work. Try this:

{{ $min($('Split In Batches').item.json.total_currency_balance, $('Split In Batches').item.json.currency_expiring) }}

The solution works:

In this example, it returns the value “27.5”, which is correct.

However, i need to send “27,50” in the next node (currency format outside US, with comma instead of period and 2 decimals).

I tried to insert .toFloat().toFixed(2).replace(“.”,‘,’), which works outside the $min(), but returns null here:

{{ $min($(‘Split In Batches’).item.json[“total_currency_balance”].toFloat().toFixed(2).replace(“.”,‘,’)
, $(‘Split In Batches’).item.json[“currency_expiring”].toFloat().toFixed(2).replace(“.”,‘,’) ) }}

Any suggestions?