How to access the flow data inside a filter

I need to compare a value from the lookup result, (for example a lookup in crm that returns an id), to a value that's been traveling throughout the flow (for example an accountID that's been imported from sql in the flow and is in the main payload that goes through the flow). How can I access the main payload of the flow inside a filter?

The lookup result could be either of the following depending on whether there's any data or not:

{
"page_of_records": [
{
"record": {}
}
]
}
OR
{
"page_of_records": [
{
"record": {
"accountID": 123,
"Name": "sample 1"
}
},
{
"record": {
"accountID": 456,
"Name": "sample 2"
}
}
]
}
and my main payload is something like this:
{
"record": {
"name": "Main name",
"id": 235,
"maccountid": 1001,
"crmdata": [
{
"crmname": "CRM Name"
}
]
}
}
1) How to check if the lookupResult.page_of_records contains an empty record. just like the first sample above?
2) How to check if the (lookupResult.Page_of_records.record.accountID == flowData.ID) and (lookupResult.Page_of_records.record.Name == flowData.Name)? This needs to iterate over all the records and see if any of them have accoutID and name both being the same as the ID and Name that's in the flow's main payload.
Thanks for helping!

Hello Bahman,

Are you using a response mapping on your lookup step?

If you are using a lookup step in your flow, you will need to add response mapping to add those lookup results to the record to be used later in the flow such as a filter in your use case.

In the screenshot below, I have circled in red where I have added a response mapping on the step where I am looking up additional data. I then can use that response in the next step which is a filter (circled in blue)

Thanks Nate,

So the import filter basically skips records that don't pass the filtering criteria, but the record will still continue travelling through the flow. I don't want that though, I need the records that do not match to be processed differently. (Now here I got my answer by trying a couple of different things based on your answer so I truly appreciate your help).

I found out that I need the field mapping as well as a branching logic in which I can compare the values and decide how should each record be processed based on the criteria they meet.

Cheers!

Yes you are correct! This would be a use for flow branching instead of filtering.