Forum Discussion
How to use SQL query criteria stored in a column to return data using a function or Table.SelectRows
- 6 years ago
Oh good grief ImkeF - duh!
Thanks! So obvious. I was looking for something difficlut.
Anonymous - the final formula for the filter is:
= Table.AddColumn( #"Changed Type", "Custom", each let varFilter = [Criteria] in Table.SelectRows(Table, Expression.Evaluate("each" & varFilter, [_ = _])) )Here is the final link. I keep files in a different folder when they are solved. The above link will not work.
- Anonymous6 years ago
Wow camargos88 edhans ImkeF I usually never post questions on forums like this because I always thought it took days to get answers. You proved me wrong, less than 24 hours and I have some info to work with. I will try to apply your solutions to my actual case and let you know the outcome! Thanks!
- 6 years ago
Glad to help Anonymous
Remember, everyone here is a volunteer. Sometimes stuff can take days, other times minutes. Always post. Even if you discover a workable solution first, you can get a different perspective here that might improve on your solution.
Hi Anonymous ,
Does your table Lookup have this the second column like this (Type = “Shirt”) ?
If yes, it's possible to query using table function, but more work.
If no, show us your base table and we can help you.
Hi Ricardo,
Thanks for replying!
I can't share the actual data, but the criteria column contains information like this:
((Type = "Shirt" AND Size ="XL") OR (Type = "Shirt") OR (Color = "Red")) AND Someother field = "X"
The complexity is that each row is different and uses different fields in a different order.
Can you help me with a function I can use?
- edhans6 years ago
Community Champion
I feel like I am close here, but this is returning an error:
= Table.AddColumn( #"Changed Type", "Custom", each let varFilter = [Criteria] in Table.SelectRows(Table, Expression.Evaluate(varFilter, [_ = _])) )The problem is I am getting this error:
ImkeF - can you see what I'm doing wrong here?