# Summarize terms in a record

**URL:** <https://community.dynatrace.com/t/summarize-terms-in-a-record/44886>\
**Category:** DQL\
**Tags:** dql, logs\
**Created:** [March 27, 2024, 2:40pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886 "2024-03-27T14:40:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![wellpplava](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wellpplava](https://community.dynatrace.com/u/wellpplava)\
**Post date:** [March 27, 2024, 2:40pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/1 "2024-03-27T14:40:39Z")

</div>

Hello!

I have log lines when a customer makes a purchase. This log contains the ID of the purchased products. I would like to be able to quantify the best-selling products of the day.

Example:

message: TUP15451, TUP41234, TUP52351152.

It’s possible?

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [March 27, 2024, 4:17pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/2 "2024-03-27T16:17:06Z")

</div>

Considering the productID is a field, you can do "| summarize count(), by: {productID} " at the end of your query.

> **[summarize - DQL aggregation commands](https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/commands/aggregation-commands#summarize)**
>
> The fieldsSummary command calculates the cardinality of field values that the specified fields have. | DQL aggregation commands

---

<div class="post-metadata">

**Author:** ![wellpplava](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wellpplava](https://community.dynatrace.com/u/wellpplava)\
**Post date:** [March 27, 2024, 5:23pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/3 "2024-03-27T17:23:35Z")

</div>

but I have multiple products, something like: “PRODUCTS: TPU 123, TPU 1942, TPU9724”

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [March 27, 2024, 5:26pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/4 "2024-03-27T17:26:20Z")

</div>

You mean, in the same line you have multiple values for the productID field?

---

<div class="post-metadata">

**Author:** ![wellpplava](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wellpplava](https://community.dynatrace.com/u/wellpplava)\
**Post date:** [March 27, 2024, 5:33pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/5 "2024-03-27T17:33:34Z")

</div>

Yes!!

I’m almost there!What’s left is to refine my parseAll because it’s not getting the last value

> [@dannemca](https://community.dynatrace.com/user/18264)&nbsp;wrote:
> 
> You mean, in the same line you have multiple values for the productID field?

data record(timestamp = “12/24/2022”, content = “Products: SKU1234, SKU1234, SKU12345”),  
record(timestamp = “12/25/2022”, content = “Products: SKU123, SKU1234, SKU12345”)

| fieldsAdd ProductID = parseAll(content, “BLANK LD:pid PUNCT”)  
| expand ProductID  
| summarize count(), alias: Occurrences, by:ProductID

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [March 27, 2024, 5:47pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/6 "2024-03-27T17:47:54Z")

</div>

Got it now, try to replace the LD by WORD in your parseAll:

```markup
data record(timestamp = "12/24/2022", content = "Products: SKU1234, SKU1234, SKU12345"),
record(timestamp = "12/25/2022", content = "Products: SKU123, SKU1234, SKU12345")
| fieldsAdd ProductID = parseAll(content, "BLANK WORD:pid")
| expand ProductID
| summarize count(), alias: Occurrences, by:ProductID

```

Regards.

---

<div class="post-metadata">

**Author:** ![wellpplava](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wellpplava](https://community.dynatrace.com/u/wellpplava)\
**Post date:** [March 28, 2024, 1:32pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/7 "2024-03-28T13:32:46Z")

</div>

[@dannemca](https://community.dynatrace.com/user/18264)

We received the official registration format. Perhaps it would be possible to adapt parse to capture what is just between {[[and]]}?

I tried with DATA “{[[” but I was unsuccessful

PARITY\_CATEGORY and fields: {[[TKU12345, TKU123456, TKU123451, TKU59156]]}

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [March 28, 2024, 6:22pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/8 "2024-03-28T18:22:32Z")

</div>

If you have comma separated array of words it quite easy to do using just DPL or DPL + splitString:

```markup
data record(content="blabla blabla Products: {[[TKU12345, TKU123456, TKU123451, TKU59156]]} bla bla")
| parse content, "DATA '{[[' LD:products ']]}' DATA" 
| fieldsAdd product=trim(splitString(products,",")[])

```

or

```markup
data record(content="blabla blabla Products: {[[TKU12345, TKU123456, TKU123451, TKU59156]]} bla bla")
| parse content, "DATA '{[[' ARRAY{WORD*:i ', '*}{1,100}:product ']]}' DATA"

```

 ![krzysztof_hoja_0-1711650130772.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/3/036a6bbf2e6eefbcdb93837a5da9d9231e0140e5.png)

Kris

---

<div class="post-metadata">

**Author:** ![wellpplava](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wellpplava](https://community.dynatrace.com/u/wellpplava)\
**Post date:** [March 28, 2024, 8:05pm UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/9 "2024-03-28T20:05:11Z")

</div>

```auto
| parse content, "DATA '{[[' ARRAY{WORD*:i ', '*}{1,100}:product ']]}' DATA"

```

this worked great! Thank you very much!

Could you explain to me how it works?

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [March 29, 2024, 6:31am UTC](https://community.dynatrace.com/t/summarize-terms-in-a-record/44886/10 "2024-03-29T06:31:23Z")

</div>

Doc page for this:&nbsp;[DPL Array — Dynatrace Docs](https://docs.dynatrace.com/docs/platform/grail/dynatrace-pattern-language/log-processing-array)
