# Get the value in a column when the according to condition in another column value approximately equal

**URL:** <https://discourse.julialang.org/t/get-the-value-in-a-column-when-the-according-to-condition-in-another-column-value-approximately-equal/86563>\
**Category:** New to Julia\
**Tags:** question, dataframes\
**Created:** [August 30, 2022, 5:38pm UTC](https://discourse.julialang.org/t/get-the-value-in-a-column-when-the-according-to-condition-in-another-column-value-approximately-equal/86563 "2022-08-30T17:38:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayodyas](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@ayodyas](https://discourse.julialang.org/u/ayodyas)\
**Post date:** [August 30, 2022, 5:38pm UTC](https://discourse.julialang.org/t/get-the-value-in-a-column-when-the-according-to-condition-in-another-column-value-approximately-equal/86563/1 "2022-08-30T17:38:14Z")

</div>

I have a dataframe

```julia
      using DataFrames
      df1=DataFrame(p1 = [10, 20, 30,40,50], p2 = [50,5, 60,70.2,40])

```

I wanted to get the value of column p1, when the value of p2 is approximately equal to my input  
I have filtered the required one by

> id=df1[in(40).(df1.p2), :p1]

I wanted to modify the such that I will get the same result even if the given value is approximately equal. Instead of 40, 40.5 should also work or just when the value \>=40 (first occurrence)

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [August 30, 2022, 5:49pm UTC](https://discourse.julialang.org/t/get-the-value-in-a-column-when-the-according-to-condition-in-another-column-value-approximately-equal/86563/2 "2022-08-30T17:49:45Z")

</div>

Just use a condition with a desired precision, e.g.:

```julia
julia> df1[25 .< df1.p2 .< 55, :p1]
2-element Vector{Int64}:
 10
 50

```

to get all rows where `p2` is in `[25, 55]` range.
