Question: I am trying to perform a query using ndb in appengine as follows

```
all_adverts = AdModel.query(AdModel.daily_used < AdModel.daily_budget)

```

I am trying to query only items that have not used their daily maximum of their advertising campaign budget. However when I run this I get the following exception:

```
BadValueError: Expected float, got FloatProperty('daily_budget', default=1)

```

Is this simply not possibile with ndb or am I structuring the query incorrectly?

Answer: 
Your query needs to scan all of the same kinds which is not the typical usage for datastore.

An easier walkaround is use `ComputedProperty`. Then filter with this property.
Of course this changes will only affects later entity updates.

```
class AdvertModel(ndb.Model):
    daily_used = ndb.FloatProperty()
    daily_budget = ndb.FloatProperty()
    in_money = ndb.ComputedProperty(lambda self: self.daily_used < self.daily_budget)

```
You need to understand that the query mechanism is needs a value on the right hand side of the comparison, not another property. Its not a limitation of ndb, but how the underlying architecture works. Hence the error you are getting `BadValueError: Expected float, got FloatProperty('daily_budget', default=1)` . The other answers are your best bet for the required functionality.