Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi all,
I'm trying to use the LikeFilter infotable function to filter some results in an infotable. I'm using the basic syntax like below:
var paramsForFilteredResult = {
inclusive: true,
fieldName: "ResultID",
t:MyInfotableResult,
pattern: "Result1"
};
var FilteredByResult = Resources["InfoTableFunctions"].LikeFilter(paramsForFilteredResult);
But I am wondering, is it possible using this function to search for multiple patterns? For example, what if I want to show Result1 and Result2, not just Result1? I have tried incorporating forloops and a number of different syntax approaches, but I don't seem to be having luck.
Any help is greatly appreciated!
- Jon
Solved! Go to Solution.
Hi Jon,
I did exactly a few hours ago a query to an Infotable, that's the exact code ( like it's the query string text ):
if (like) {
result = Resources["InfoTableFunctions"].Query({
t: result,
query: {
"filters": {
"fieldName": "name",
"type": "LIKE",
"value": ("*"+like+"*")
}
}
});
}
Usually for more complex filters I use Query
and this reference in the javadoc
Thanks, Pai. I'll check it out.
This was a big help! Thank you, Pai.
One question: I'm trying to use LIKE with a wildcard, but I'm not having luck. Here's what I'm trying:
"fieldName": "SystemStatus",
"type": "LIKE",
"value": "%Reason1%"
Is it as simple as this to return values? It isn't working for me. I also tried '*' + "Reason1" + '*' and a few other variations.
thanks,
Jon
Hi Jon, did you try something like this "value": "*%Reason1%*"
I have tried that, but it doesn't seem to be working.
Jon,
Did you tried how I did sent to you? if it doesn't works, the problem should be another. You are querying directly a DataTable, Stream, ValueStream or a in-memory Infotable?
Best Regards,
Carles.
Hi Jon,
I use LIKE that way and it works:
{ "fieldName": "queryFieldName", "type": "LIKE", "value": ("*"+likeText+"*") }
Hi Jon, You can use most of the regular expression that a java script supports, like Carles mentioned you can use '*' to filter data. Also day if you want to filter data while has 'Result' as prefix followed by a number then you can use "Result\\d", in this case you will get Result1, Resut2 but not Results ot Results1.
Another exaple is, if you want to filter all records with values a or b or c then you can use "[abc]"
Hope this helps,
Regards,
Siva
Thanks for the followup, everyone.
I am working to implement what Charles mentioned, but am having some server issues at the moment. Will get it up and tested as soon as I can. Charles, I am trying to query an infotable.
Hi Jon,
I did exactly a few hours ago a query to an Infotable, that's the exact code ( like it's the query string text ):
if (like) {
result = Resources["InfoTableFunctions"].Query({
t: result,
query: {
"filters": {
"fieldName": "name",
"type": "LIKE",
"value": ("*"+like+"*")
}
}
});
}
Awesome. Thanks for sharing! I will test it out as soon as I can.
Worked like a charm. Thanks so much for the help. I just used this in an "or" statement to give me what I needed.
"filters": {
"type": "Or",
"filters": [
{"fieldName": "OrderType","type": "LIKE","value": "OrderType1"},
{"fieldName": "OrderType","type": "LIKE","value": "OrderType2"}
]}