Filter rows in workshop by comparing two properties

Hello,

I’m trying to filter rows of objects in Workshop based on a comparison between two of their properties, both of which are of date type.

I haven’t been able to find a straightforward way to do this directly within Workshop’s filtering interface. Additionally, when attempting to implement this logic using Python functions in Workshop, it seems that comparing two properties within the same function is not supported.

Could you please advise if there is any method or workaround to filter data by comparing two properties in Workshop?

+) Is there any way to adjust relative timedelta method to specific property, and use it on comparing two properties?

example code

old_REDACTED_lv2 = (
    client.ontology.objects.REDACTED
    .init_from_object_set_rid(
        _old_REDACTED.get_object_set_rid()
    )
    .where( (REDACTED.delivery_date >= REDACTED.notification_date) ) ### -> this code return error
    # .where(REDACTED.delivery_date >= REDACTED.notification_date + timedelta(365)) ## -> what i really want to do

error log

ValueError: cannot process 'deliveryDate >= Property['notificationDate']': 'Property['notificationDate']' should be a 'date'.

Thank you

Hi @daleKwon,

A simple way of doing this would be in your pipeline – but I guess that these dates will likely change, which is why you’re looking for a more dynamic solution. Let me know if this assumption is wrong.

I am not sure how well the integration of date in Python functions are – in case you want to try with a TypeScript-function, something like this would work:

@Function()
public async filterByProperties(yourObjects: ObjectSet<YourObjectType>): Promise<YourObjectType[]> {
    const objectPromises = await yourObjects.filter((obj => 
        obj.deliveryDate && obj.notificationDate && 
        !obj.deliveryDate.isBefore(obj.notificationDate.plusYears(1))
    );
    return await Promise.all(objectPromises);
}

Let me know if this solves your problem.