I’m trying to do a simple filter in a table and I’m having difficulties in understanding why it doesn’t work.
Here are 2 tables. One is a list of tickets, and for each we can assign an problem using a lookup to the second table.
The second table, the list of problems, compute how many tickets are assign per problem, and propose a solution.
I want the solution to be displayed in the first table with each ticket as well, so I thought I could just use a formula with a filter to find the row in list of problem that matches current rows problem, but i doesn’t work. It outputs every row instead.
I’m not really good at explaining in English but I’ll take a try.
Whenever you use the filter function you have to use currentValue.
The filter will then compare each value (currentValue) from a list (List of problem in you case) to something else (In your case, each row value from the column Problem- thisRow.Problem).
The way it is, your formula is not filtering any data, so it returns [List of problem].solution
@Breno_Nunes, just as a clarification: while in this case it’s true, it is not the rule.
@CurrentValue is a convenient variable holding a reference to the context in several situations.
For instance
[List of problems].Filter(CurrentValue=thisRow.Problem): @CurrentValue here holds the reference of any of the problem of the list.
Sequence(1,10).FormulaMap(CurrentValue): here it holds the index of the iteration (1,2,3…)
Filter() formula needs a condition. Tasks.Filter(Status != "done" && Priority="High"): you access to properties (columns) of Tasks object (table) to select the condition.
You could write it as: Tasks.Filter(CurrentValue.Status != "done" && CurrentValue.Priority="High"): as you can see, the CurrentValue is unnecessary.
But when you have to check the whole object, then you have to use it, like in the case of this post, as you correctly pointed out.
Coda even shows you so when you are writing a formula. It’s the same thing for ‘thisRow.column’ that some times can be written as ‘column’ only.
Filter formula is practically useless without ‘CurrentValue’
Please, correct me if I’m wrong but that is the way I understand it.