Query Loki data source based on multi-value variable (IP address)

I’m trying to find a way to build a query in Grafana to get all records from Loki data source based on a custom variable I defined as follows -

- variable type: custom
- variable name: hidden_networks
- show on dashboard: label and value
- values separated by comma: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
- multi-value: enabled

My very basic query currently looks like this:

{service_name="nginx"}

but what I’m trying to achieve is:

{service_name="nginx"} | json | remote_addr != ip("${hidden_networks}")

Unfortunately this doesn’t work, because the ‘ip’ function takes only one argument and the dashboard variable is configured as multi-value. If I disable multi-value functionality on the hidden_networks variable, everything is working as expected, but I need ability to select multiple CIDR networks and hide them from logs.

Is there a way to ‘unpack’ the list of values in a multi-value variable and add a dedicated | remote_addr != ip(xxx) to the query for each value individually?