# Transform --\> Default a pivot groupBy keyName is does not exist

**URL:** <https://discuss.elastic.co/t/transform-default-a-pivot-groupby-keyname-is-does-not-exist/303871>\
**Category:** Elasticsearch\
**Tags:** transforms\
**Created:** [May 3, 2022, 7:43pm UTC](https://discuss.elastic.co/t/transform-default-a-pivot-groupby-keyname-is-does-not-exist/303871 "2022-05-03T19:43:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lupolo](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@lupolo](https://discuss.elastic.co/u/lupolo)\
**Post date:** [May 3, 2022, 7:43pm UTC](https://discuss.elastic.co/t/transform-default-a-pivot-groupby-keyname-is-does-not-exist/303871/1 "2022-05-03T19:43:52Z")

</div>

In a transform under the section of "pivot": and "group\_by": I would like to default a value if keyName does not exist. Example:

```auto
<if query_parameters.partnerId does not exists:
   partnerId=null
else:
   partnerId=query_parameters.partnerId/>

```

I tried to do the following:

```auto
 "partnerId": {
        "terms": {
          "field": "query_parameters.partnerId",
           "missing": "NULL"
        }

```

But it fails with this error when I provision the transform via API. If I remove "missing": "NULL" all works well but I need to set the groupBy keyName to null:

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "x_content_parse_exception",
        "reason" : "[1:124] [data_frame_terms_group] unknown field [missing]"
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[135:5] [data_frame_transform_config] failed to parse field [pivot]",
    "caused_by" : {
      "type" : "x_content_parse_exception",
      "reason" : "[135:5] [data_frame_transform_pivot] failed to parse field [group_by]",
      "caused_by" : {
        "type" : "x_content_parse_exception",
        "reason" : "[1:124] [data_frame_terms_group] unknown field [missing]"
      }
    }
  },
  "status" : 400
}

```

How can I make it work when a keyName does not exists?

Thanks,  
Lp

---

<div class="post-metadata">

**Author:** ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)\
**Post date:** [May 3, 2022, 8:06pm UTC](https://discuss.elastic.co/t/transform-default-a-pivot-groupby-keyname-is-does-not-exist/303871/2 "2022-05-03T20:06:32Z")

</div>

unfortunately transform does not support `missing`, but it supports `missing_bucket`

```auto
"missing_bucket": true 

```

This will not skip buckets where `partnerId==null`, but create them. If you want to change the value `null` to something else, you can use an ingest pipeline to post process and _set_ a value.

---

<div class="post-metadata">

**Author:** ![lupolo](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@lupolo](https://discuss.elastic.co/u/lupolo)\
**Post date:** [May 4, 2022, 1:47am UTC](https://discuss.elastic.co/t/transform-default-a-pivot-groupby-keyname-is-does-not-exist/303871/3 "2022-05-04T01:47:21Z")

</div>

Thanks for the trick. It worked. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 1, 2022, 1:47am UTC](https://discuss.elastic.co/t/transform-default-a-pivot-groupby-keyname-is-does-not-exist/303871/4 "2022-06-01T01:47:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
