# What xvalues are allowed for create\_continuous

**URL:** <https://community.riskscape.org.nz/t/what-xvalues-are-allowed-for-create-continuous/196>\
**Category:** Community\
**Created:** [9 October 2024 22:40 UTC](https://community.riskscape.org.nz/t/what-xvalues-are-allowed-for-create-continuous/196 "2024-10-09T22:40:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@JPowell](https://community.riskscape.org.nz/u/JPowell)\
**Post date:** [9 October 2024 22:40 UTC](https://community.riskscape.org.nz/t/what-xvalues-are-allowed-for-create-continuous/196/1 "2024-10-09T22:40:04Z")

</div>

This pipeline works

```auto
input(value: { x_point: [0.095,0.23], y_point: [2000,2010] })
->
unnest([x_point, y_point]) as foo
->
group({ to_lookup_table(key: x_point, value: y_point, options: { unique: true }) as lookup_table })
->
select({
	create_continuous(
	[0.095,0.23],
	x -> lookup(lookup_table, x)) as testCurve
})
->
select({
        apply_continuous(testCurve, 0.1) as y01,
        apply_continuous(testCurve, 0.2) as y02})
->
save(name: 'output.csv')

```

and produces

```auto
y01	y02
2000.37037	2007.777778

```

but if I change the create\_continuous to

```auto
create_continuous(
	[0.09 **6** ,0.23],
	x -> lookup(lookup_table, x)) as testCurve

```

then it outputs null for both results.

Setting either of the xvalues that fall above and below the requested apply\_continuous values to anything other than exactly what they are in the to\_lookup\_table call causes this behaviour.

---

<div class="post-metadata">

**Author:** ![timbeale](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@timbeale](https://community.riskscape.org.nz/u/timbeale)\
**Post date:** [9 October 2024 23:11 UTC](https://community.riskscape.org.nz/t/what-xvalues-are-allowed-for-create-continuous/196/2 "2024-10-09T23:11:19Z")

</div>

Kia ora,

This is more related to the behaviour of the `lookup()` function than it is related to `create_continuous()`. The `create_continuous()` function should basically accept any x-value range.

The problem here is the `create_continuous()` lambda expression is producing a null result for one of the x values. Normally, the `apply_continous()` tries to interpolate between the two closest x values. However, in this case one of the x values produces a null result.

Currently in RiskScape, any arithmetic involving a null value will always produce a null result, e.g.

```auto
riskscape expr eval "null_of('integer') + 2000"
<nothing>

```

So the interpolation between a valid number and null is producing a null result, which is what you’re seeing coming out of your pipeline.

The reason you’re getting a null value is because the `lookup()` function is trying to lookup a value that doesn’t exist in the table (0.096). If you changed the lambda expression to use zero instead of null, then you _would_ get non-null results from your pipeline, e.g.

```auto
input(value: { x_point: [0.095,0.23], y_point: [2000,2010] })
->
unnest([x_point, y_point]) as foo
->
group({ to_lookup_table(key: x_point, value: y_point, options: { unique: true }) as lookup_table })
->
select({
	create_continuous(
	[0.096,0.23],
	x -> if_null(lookup(lookup_table, x), 0)) as testCurve
})
->
select({
        apply_continuous(testCurve, 0.1) as y01,
        apply_continuous(testCurve, 0.2) as y02})
->
save(name: 'output.csv')

```

Hope that helps.
