# Create a visualization or filter that shows data from one query, but where some data are exclude based on another query (Left Join)

**URL:** <https://discuss.elastic.co/t/create-a-visualization-or-filter-that-shows-data-from-one-query-but-where-some-data-are-exclude-based-on-another-query-left-join/232560>\
**Category:** Kibana\
**Created:** [May 14, 2020, 6:32am UTC](https://discuss.elastic.co/t/create-a-visualization-or-filter-that-shows-data-from-one-query-but-where-some-data-are-exclude-based-on-another-query-left-join/232560 "2020-05-14T06:32:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![runewage](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@runewage](https://discuss.elastic.co/u/runewage)\
**Post date:** [May 14, 2020, 6:32am UTC](https://discuss.elastic.co/t/create-a-visualization-or-filter-that-shows-data-from-one-query-but-where-some-data-are-exclude-based-on-another-query-left-join/232560/1 "2020-05-14T06:32:38Z")

</div>

Hi  
In my data in Kibana I have one filed referring to another field. (xref -\> yref). What I want to achieve is to have a visualization showing me all data where someField = someData, except the records where xref is within another query providing all records where someField=someOtherData

![left join](https://us1.discourse-cdn.com/elastic/original/3X/5/4/541a65bdfde707841274fc91034be0171fa558bd.png)

In SQL it would have been something like this:  
Select from table A where a=b AND xref not in (select yref from table A where a=c)

I hope someone can help.

I have tried to use "span\_not" and "include"/"exclude", but it does not work. I also tried a simple query using "span\_term" which gave me no data. while the same query using "term" gives me data in return.

I am very new to Kibana (which you might already suspected). Unfortunately I have not found anything in the documentation so far to solve this use case.

Br,  
Rune Waage

---

<div class="post-metadata">

**Author:** ![cheiligers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheiligers/32/73114_2.png) [@cheiligers](https://discuss.elastic.co/u/cheiligers)\
**Post date:** [June 4, 2020, 8:11pm UTC](https://discuss.elastic.co/t/create-a-visualization-or-filter-that-shows-data-from-one-query-but-where-some-data-are-exclude-based-on-another-query-left-join/232560/2 "2020-06-04T20:11:02Z")

</div>

@runewage welcome to the community!  
It would help to know what type of visualization are you trying to create (there are [several](https://www.elastic.co/guide/en/kibana/current/visualize.html) in Kibana) and what the shape of your documents is. You should be able to use a combination of filters to get the visualization you need. Using your example from above, you'd create a visualization that shows you where "someField = someData" and then use a filter to filter out where "someField=someOtherData" (i.e add a filter for "someField" _is not_ "someOtherData". I hope that helps!

---

<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:** [July 2, 2020, 8:11pm UTC](https://discuss.elastic.co/t/create-a-visualization-or-filter-that-shows-data-from-one-query-but-where-some-data-are-exclude-based-on-another-query-left-join/232560/3 "2020-07-02T20:11:27Z")

</div>

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