# \[Visualization\]\[Treemap\] Multiple object case

**URL:** https://discuss.elastic.co/t/visualization-treemap-multiple-object-case/280170
**Category:** Kibana
**Tags:** lens
**Created:** [August 2, 2021, 1:54am UTC](https://discuss.elastic.co/t/visualization-treemap-multiple-object-case/280170 "2021-08-02T01:54:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kwang\_hee\_Han](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kwang_hee_han/32/34412_2.png) [@kwang\_hee\_Han](https://discuss.elastic.co/u/kwang_hee_Han)
#### Post date: [August 2, 2021, 1:54am UTC](https://discuss.elastic.co/t/visualization-treemap-multiple-object-case/280170/1 "2021-08-02T01:54:56Z")

</div>

Hello,

I have tried creating "TreeMap" visualization in Lens. I couldn't get appropriate Visual. I need help to customizing.

![image](https://us1.discourse-cdn.com/elastic/original/3X/c/f/cff8bc4431276f8e71f99fc72888949448fb8c96.png)  
[Indexed Document Schema]

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/c/7c9925d342cc0e913d4c16d27d84a3f98487ac80.png)  
[TreeMap in Lens]

Attached first imaged tells, category : ":ThmRgc" pair with ":Us", and other ":ThmSec" pair with ":It", but when I tried setting "group by" field in Lens Visualization, "first- category", "second - code" Their result is not correct to me.

One example, ":Us" value must belongs to ":ThmRgc" category only, but "Lens" display ":Us" belongs both all ":ThmRgc" and ":ThmSec".  
Onother case ":It" value must belongs to ":ThmSec" category only, but "Lens" visualize ":It": belongs both all ":ThmRgc" and ":ThmSec".

I think that "flatten" would be a problem which invoke this incorrect result.

I want to ":It" only group by ":ThmSec", and ":Us" must group only ":ThmRgc" . How can I generate correct treemap?

---

<div class="post-metadata">

### Author: ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)
#### Post date: [August 2, 2021, 7:20am UTC](https://discuss.elastic.co/t/visualization-treemap-multiple-object-case/280170/2 "2021-08-02T07:20:57Z")

</div>

Hi @kwang_hee_Han I am not sure I understand, but just to confirm, you want to filter out only documents that both contain `:Us` and `:ThmRgc` OR `:It` and (`:ThmRgc` and `:ThmSec`)?  
Instead of creating nested top values aggregation, maybe you could use filters? Here's the tutorial example:

> **[Build your first dashboard | Kibana Guide \[7.13\] | Elastic](https://www.elastic.co/guide/en/kibana/current/create-a-dashboard-of-panels-with-web-server-data.html#treemap)**

Your KQL first example would be: `fieldname1 : :us AND fieldname2: :ThmRgc`

---

<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: [August 30, 2021, 7:21am UTC](https://discuss.elastic.co/t/visualization-treemap-multiple-object-case/280170/3 "2021-08-30T07:21:42Z")

</div>

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