Hi, is there any way to filter on a calculated column in a query?
I was able to make it work using a search box and modify the actual query:
But, it would be handier to be able to quickly filter on the calculated columns.
Hi, is there any way to filter on a calculated column in a query?
I was able to make it work using a search box and modify the actual query:
But, it would be handier to be able to quickly filter on the calculated columns.
Hey there @cliff-brake! Unfortunately the table filter feature doesn’t support calculated columns quite yet. I would love to move this post into the #feature-requests category if you’re cool with that!
Also, is there a way to modify the above query to fetch all records if {{ imei.value}} is not set, or equal to “”. This would allow viewing all records if imei.value is not set.
Yes, that would be a great feature, please feel free to move this.
@cliff-brake yes indeed there is a way to do that! I use regex in my Mongo queries and then add in this ternary operator (in the example here, I’m querying the name
property):
{name: {"$regex": {{ !search_box.value ? {$exists: true} : search_box.value }}, "$options": "i"}
So if there’s no value in the search_box
then it returns all results, and if there is a value, it filters on that value. More details in this community post here: How to create a dynamic query without changing resource settings?
Let me know if this helps!
@justin yes, that works. Ended up with:
{"state.modemInfo.imei": {{ imei.value ? imei.value : {$exists:true} }} }
Awesome Keep posting if there’s anything else we can help with!