# If condition in Kibana Table Visualization

**URL:** <https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751>\
**Category:** Kibana\
**Created:** [May 26, 2022, 8:05pm UTC](https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751 "2022-05-26T20:05:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![micaelle](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@micaelle](https://discuss.elastic.co/u/micaelle)\
**Post date:** [May 26, 2022, 8:05pm UTC](https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751/1 "2022-05-26T20:05:45Z")

</div>

Hi, is it possible to use if condition in a Kibana Table Visualization?

I want to build a financial table that counts a line item and then multiply the quantity with a specific value for each volume level.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 26, 2022, 8:13pm UTC](https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751/2 "2022-05-26T20:13:00Z")

</div>

Hi @micaelle Welcome to the community

What version are you on?

Have you tried the Lens Table with Formulas? Perhaps that will be a good fit.

Here is a nice Blog with some examples

> **[10 common Kibana visualization questions answered with formulas and time travel](https://www.elastic.co/blog/kibana-10-common-questions-formulas-time-series-maps)**
>
> Kibana advanced analytics features enable you to tackle time series and geospatial data questions. Learn how to use formulas for calculations like ratios, week over week, deviations, and others — plus Elastic Maps tips for time / space questions.

---

<div class="post-metadata">

**Author:** ![micaelle](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@micaelle](https://discuss.elastic.co/u/micaelle)\
**Post date:** [May 27, 2022, 2:59pm UTC](https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751/3 "2022-05-27T14:59:38Z")

</div>

I had checked out this blog before but it didn't really help. I'm using Kibana version 8.1.3. what I need is to create a condition that depends on 3 of the 10 existing fields of an index, so if the count of these fields is greater than 100, I will need to do the multiplication by 2, if it is greater than 1000 by 3, and so on.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 27, 2022, 3:05pm UTC](https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751/4 "2022-05-27T15:05:09Z")

</div>

I think with that kind of logic you may need to create a new field on ingest with and ingest pipeline or a runtime field (Which has full conditional logic)

I don't think formulas in Lens do conditional logic yet... but there are `mod` functions etc... so perhaps you could...

if you provided samples of the data ... the formula and expected results perhaps someone could help...

---

<div class="post-metadata">

**Author:** ![micaelle](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@micaelle](https://discuss.elastic.co/u/micaelle)\
**Post date:** [May 30, 2022, 3:47pm UTC](https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751/5 "2022-05-30T15:47:59Z")

</div>

I have the data about the transactions made by the users and also about the accounts that made those transactions. I need to count how many accounts there are and how many pix there were and if the amount of accounts is less than 100 and the amount of pix is less than 500, the total cost will be 2,000.00, if the amount of accounts is less than 200 and the amount of pix less than 1000, the total cost will be 4,000.00.

The formula I'm still building because I'm a beginner in elastic, but the condition would be like count(operations.keyword pix.sent) + count(operations.keyword pix.received) \<500 and unique\_count(account\_id.keyword) \<100 then

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

---

<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:** [June 1, 2022, 8:34am UTC](https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751/6 "2022-06-01T08:34:24Z")

</div>

Hi @micaelle,

while there's no current conditional helpers yet available in Lens, it is possible to achieve something like you want using some math. I've written some explanation in here on how to leverage the `clamp` function for this use case: [Dec 4th, 2021: [en] Advanced trick and tips in Lens](https://discuss.elastic.co/t/dec-4th-2021-en-advanced-trick-and-tips-in-lens/289935#comparing-against-a-static-value-7)

In your example, you probably have to add one more layer of complexity there as you depends on two distinct conditions:

```auto
(
clamp( count(operations.keyword pix.sent) + count(operations.keyword pix.received) - 500, 0, 1) + 
clamp( unique_count(account_id.keyword) - 100, 0, 1)
) * 2000

```

---

<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 29, 2022, 8:34am UTC](https://discuss.elastic.co/t/if-condition-in-kibana-table-visualization/305751/7 "2022-06-29T08:34:37Z")

</div>

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