Forum Discussion
tanacal
Mar 02, 2025Brass Contributor
Filter a table with an array list
Hi,
Can you someone help me to filter a table with array list? Is that possible? Thanks,
What do you mean by "Filter a table with array"? Here few approach from assumption.
=FILTER(TblData2,COUNTIFS(G2:G3,TblData2[Year]))=GROUPBY(TblData2[Year],TblData2[Amount],SUM,0,0)
2 Replies
- Harun24HRBronze Contributor
What do you mean by "Filter a table with array"? Here few approach from assumption.
=FILTER(TblData2,COUNTIFS(G2:G3,TblData2[Year]))=GROUPBY(TblData2[Year],TblData2[Amount],SUM,0,0) How about filtering by using Javascript:
const table = [ { id: 1, name: 'Alice', age: 25 }, { id: 2, name: 'Bob', age: 30 }, { id: 3, name: 'Charlie', age: 35 }, { id: 4, name: 'David', age: 40 } ];An array list of IDs that you want to filter by:
const arrayList = [1, 3];You can use the filter method to create a new array that includes only the rows from the table where the id is in the arrayList:
const filteredTable = table.filter(row => arrayList.includes(row.id)); console.log(filteredTable);The filteredTable will contain:
[ { id: 1, name: 'Alice', age: 25 }, { id: 3, name: 'Charlie', age: 35 } ]