Why does Using IF returns one item when comparing two expresisons

In my IF node when I check if
{{$json["zone"]}} is equal to {{$node["If Callback Query1"].json["callback_query"]["data"]}}
it outputs 1 item eventhough I have 4 matches.
However, if I hardcoded the string “Zone A” instead of using the expression {{$node["If Callback Query1"].json["callback_query"]["data"]}} I get all four matching items in the output. What should I do to solve this?

Hi @bawar, is there any chance the order and/or number of items is different on your IF node than on your If Callback Query1 node? If so, you might need to specify which item on the If Callback Query1 node you want to compare the incoming items with as described here for example.

I dont think so because its the same node for both.

IF 1 Checks if {{$json[“zone”]}} is equal to “Zone A”
IF 2 Checks if {{$json[“zone”]}} is equal to {{$node[“If Callback Query1”].json[“callback_query”][“data”]}}
The callback query data comes from pressing a button here which changes depending on what you choose
image
I just realized IF 2 only checks the first item
image
but this issue is still there hard coding “Zone A” in Value 2 works but using an expression does not.

Edit: Rearrangement

I just realized IF 2 only checks the first item

That sounds pretty much like the issue I’ve described above. Does the comparison work if you add $item(0). at the start of your expression like in the linked post?

1 Like

Yes that was it thanks a lot. I added $item(0). to Value 1 at first which made it worse but now I get it.

1 Like

Glad to hear it works now, thanks so much for confirming!