# List all tags with missing values for a certain field, in Flux

**URL:** <https://community.influxdata.com/t/list-all-tags-with-missing-values-for-a-certain-field-in-flux/24149>\
**Category:** Fluxlang\
**Tags:** influxdb, query, flux\
**Created:** [March 7, 2022, 1:06pm UTC](https://community.influxdata.com/t/list-all-tags-with-missing-values-for-a-certain-field-in-flux/24149 "2022-03-07T13:06:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moriarty](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/moriarty/32/8502_2.png) [@moriarty](https://community.influxdata.com/u/moriarty)\
**Post date:** [March 7, 2022, 1:06pm UTC](https://community.influxdata.com/t/list-all-tags-with-missing-values-for-a-certain-field-in-flux/24149/1 "2022-03-07T13:06:43Z")

</div>

In Influx 2.x, using Flux, is there a way to report all distinct tags which have missing (null) data in certain fields?

Simply put, I want to list all ‘hardware\_id’ keys which don’t have a value for field ‘heading’.

In plain old SQL, and perhaps Influx QL in v1.x, it would be the equivalent of something like this in pseudo code:

```auto
	# omited time range for brevity
	SELECT device_id
	FROM measurement 
	WHERE field = 'heading'
	AND _value is null;

```

I’ve tried fill()-ing it, to no avail:

```auto
from(bucket: "sandbox")
    |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
    |> filter(fn: (r) => r["_measurement"] == "metrics")
    |> filter(fn: (r) => r["_field"] == "heading")
	
    // fill empty records with an arbitrary value
    |> fill(column: "_value", value: -999.0)

    // attempt to filter on these empty records
    |> filter(fn: (r) => r["_value"] == -999.0)

```

And I’ve also noticed the exists operation, but the documentation part is unclear for me on how this can be applicable:

```auto
from(bucket: "sandbox")
    |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
    |> filter(fn: (r) => r["_measurement"] == "metrics")
    |> filter(fn: (r) => r["_field"] == "heading")
    |> filter(fn: (r) => ({
	      r with
	      human_readable:

	      	// does not work, not sure if this even makes sense?
	        if exists r._value then r["foo"] = true
	        else r["foo"] = false
    }))

```

Any help would be very much appreciated.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [March 7, 2022, 4:32pm UTC](https://community.influxdata.com/t/list-all-tags-with-missing-values-for-a-certain-field-in-flux/24149/2 "2022-03-07T16:32:40Z")

</div>

Hello @moriarty,  
I believe you can just do:

```auto
|> from(bucket: "my bucket")
|> filter(fn: (r) => r._measurement == "measurement")
|> filter(fn: (r) => r._field == "heading")
|> filter(fn: (r) => not exists r._value)
|> group()
|> unique(column: "device_id")

```

> **[unique() function | Flux 0.x Documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/unique/)**
>
> unique() returns all records containing unique values in a specified column.

> **[Operators in the Flux language | Flux 0.x Documentation](https://docs.influxdata.com/flux/v0.x/spec/operators/#logical-operators)**
>
> Flux supports many types of operators including arithmetic operators, comparison operators, function operators, and others.

---

<div class="post-metadata">

**Author:** ![maggie](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/maggie/32/3935_2.png) [@maggie](https://community.influxdata.com/u/maggie)\
**Post date:** [August 6, 2023, 6:09pm UTC](https://community.influxdata.com/t/list-all-tags-with-missing-values-for-a-certain-field-in-flux/24149/3 "2023-08-06T18:09:08Z")

</div>

I am searching for a suitable predicate to delete data where a specific tag (here: “item”) doesnt exist.  
I can query the data with the `not exists` operator but i can not delete it with

```auto
curl --request POST http://.../api/v2/delete\?org\=...\&bucket\=... \
  --header 'Authorization: Token ...' \
  --header 'Content-Type: application/json' \
  --data '{
    "start": "2019-01-01T00:00:00Z",
    "stop": "2024-01-01T00:00:00Z",
    "predicate": "_measurement=\"name\" AND not exists item"
  }'

```

but i didnt find a documentation how to do this with the CLI approach. Can you give a hint?
