# Show data in a Dashboard/Visualization only if a condition is met - Anonymization of Data

**URL:** <https://discuss.elastic.co/t/show-data-in-a-dashboard-visualization-only-if-a-condition-is-met-anonymization-of-data/341495>\
**Category:** Kibana\
**Tags:** lens\
**Created:** [August 23, 2023, 3:07pm UTC](https://discuss.elastic.co/t/show-data-in-a-dashboard-visualization-only-if-a-condition-is-met-anonymization-of-data/341495 "2023-08-23T15:07:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JD11](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jd11/32/124897_2.png) [@JD11](https://discuss.elastic.co/u/JD11)\
**Post date:** [August 23, 2023, 3:07pm UTC](https://discuss.elastic.co/t/show-data-in-a-dashboard-visualization-only-if-a-condition-is-met-anonymization-of-data/341495/1 "2023-08-23T15:07:11Z")

</div>

Hi together,

I have to create a visualization that MUST only show the data/graphic if a condition is met.

More context to this question:  
In Elasticsearch we have docs containing the stock information of different **bicycles**.  
The **bicycles** are **owned** by different **dealers**.  
Each **dealer** can set their **own price** for each bicycle.

I want a visualization that shows the average price of a bicycle model within the stock, BUT this information can only be shown if **at least 5 dealers have the same bicycle model in stock**.

This condition ( **at least 5 dealers have the same model** ) must be met due to a PRIVACY POLICY. So, if the condition is not met, the visualization should not show any information.

Is this possible?  
If yes, could you please give me a hint.

Thank you in advance.

Jay D.

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [August 25, 2023, 9:42am UTC](https://discuss.elastic.co/t/show-data-in-a-dashboard-visualization-only-if-a-condition-is-met-anonymization-of-data/341495/2 "2023-08-25T09:42:16Z")

</div>

Hi @JD11,

Welcome to the community! I'm not aware of a way to hide the visualization based on a condition, but you should be able to use a condition in the visualization to filter the data:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/d/2d47b5a26b0aed9571a2fe0a86a76ed3e1b45058.png)

It will show a no results found message if no documents match the condition:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/c/ccd564b861f3d9bfff597b2f73c76aaa0c1cdcd9.png)

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [August 25, 2023, 10:54am UTC](https://discuss.elastic.co/t/show-data-in-a-dashboard-visualization-only-if-a-condition-is-met-anonymization-of-data/341495/3 "2023-08-25T10:54:43Z")

</div>

While this is not strictly a filter, you could use a Lens Formula to achieve something similar.

Here I created an example of `AvgTicketPrice` for GB only if there are 3 Carriers than have flights that lands in that country:

```auto
ifelse(unique_count(Carrier, kql='DestCountry: GB') > 3, average(AvgTicketPrice), 0)

```

 ![Screenshot 2023-08-25 at 12.51.23](https://us1.discourse-cdn.com/elastic/original/3X/6/0/60b544d2eba3cc0c8b604a35386cdd20d87ab382.png)

In case the criteria is not met then `0` (or any value you put in there) will be shown.

Note that this is just a visualization trick and it is still possible to inspect the raw response from Elasticsearch which contains the `average(AvgTicketPrice)` value (the condition is evaluated only on the client, the server is not aware of it).

---

<div class="post-metadata">

**Author:** ![JD11](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jd11/32/124897_2.png) [@JD11](https://discuss.elastic.co/u/JD11)\
**Post date:** [August 28, 2023, 7:16am UTC](https://discuss.elastic.co/t/show-data-in-a-dashboard-visualization-only-if-a-condition-is-met-anonymization-of-data/341495/4 "2023-08-28T07:16:08Z")

</div>

Thank you Carly and Marco for your answers.

Marco, your suggestion is very helpful. Since the EU has rigorous privacy/data policies, I still need to hide that information in the raw response.

My approach will be to use this Lens formula and embed the dashboard in a website that filters the raw data in these responses.

---

<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:** [September 25, 2023, 7:17am UTC](https://discuss.elastic.co/t/show-data-in-a-dashboard-visualization-only-if-a-condition-is-met-anonymization-of-data/341495/5 "2023-09-25T07:17:06Z")

</div>

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